Read the txt file will be combined into a specific format text line

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

A net friend asked to read some data from the TXT text file, and then the combined data for the specific format. The thesis is as follows, just started describing the requirements not too clear, then add a complete.

Insus.NET think this topic text reading skill practice pieces, so try to achieve. Methods may not be the best.

First, create a class, designed to handle text file for each line of text. Because each line of text will be divided into two sections, so that the two attribute to store. Static TryParse () is to judge whether it meets the requirements of text line. Blank lines do not deal with, is not blank, some 3 spaces. Then the first assigned to the first attribute of E1, the second and third section combination and assigned to the second attributes E2. The last is to write override  ToString () method;.

Next, we start processing text files, the first is to obtain the physical path of the text file, and then read the file.

Declaring an anonymous variable result.

To meet the requirements of each line of text lines written in result to.

Finally is the output of the result set.

Webpage operation effect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ailin at November 18, 2013 - 10:37 PM