CRC Check Program 3: Open TXT file via form program get data source, byte-by-bit CRC check

Source: Internet
Author: User

In the previous article, the CRC.exe that generated the output will become the built-in module for this form application.

Create a new Windows Forms application called Crclick. Locate the application CRC.exe from the console application and copy it to the Debuge folder in the Crclick folder. There are also Test.txt for testing.

Open the Form design page, insert two textbox and a button, the length textbox is used to display the absolute path of the verified file, and the short textbox displays the final check code. button to fire the selected file window. The design is as follows:

For the trigger event of a button, we generate a OpenFileDialog control, which is used to read and open the file. The specific code is as follows: File Form.cs

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Diagnostics;6 usingSystem.Drawing;7 usingSystem.IO;8 usingSystem.Linq;9 usingSystem.Text;Ten usingSystem.Threading.Tasks; One usingSystem.Windows.Forms; A  - namespaceCrclick - { the      Public Partial classCrclick:form -     { -          PublicCrclick () -         { + InitializeComponent (); -         } +  A         Private voidButton1_Click (Objectsender, EventArgs e) at         { -Stream MyStream =NULL; -OpenFileDialog OpenFileDialog1 =NewOpenFileDialog (); -Openfiledialog1.initialdirectory =@".. \.. \.. \crclick\crclick\bin\debug"; -Openfiledialog1.filter ="txt files (*.txt) |*.txt| All Files (*. *) |*.*"; -Openfiledialog1.filterindex =2 ; inOpenfiledialog1.restoredirectory =true ; -  to      if(Openfiledialog1.showdialog () = =DialogResult.OK) +      { -          Try the          { *              if((MyStream = Openfiledialog1.openfile ())! =NULL) $              {Panax Notoginseng                  using(MyStream) -                  { theRoute. Text =Openfiledialog1.filename; +  AProcess Pro =NewProcess (); thePro. Startinfo.filename ="CRC.exe"; +Pro. Startinfo.useshellexecute =false; -Pro. Startinfo.arguments =route. Text; $Pro. Startinfo.redirectstandardoutput =true; $Pro. Startinfo.redirectstandardinput =true; - Pro. Start (); -Crcresult.text =Pro. Standardoutput.readtoend (); the  -                  }Wuyi              } the          } -          Catch(Exception ex) Wu          { -MessageBox.Show ("error:could not read file from disk. Original Error:"+Ex. Message); About          } $      } -         } -     } -}

from 39 to 49 lines, when the file selection is finished, click "Open" after the trigger event, the absolute path of the file is displayed in the Long text box, while calling the process CRC.exe operation, the results are output in a short box ,

The result is

So, a CRC calibration program is complete!

Need source code and source files can leave a message (^>^)

CRC Check Program 3: Open TXT file via form program get data source, byte-by-bit CRC check

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.