Click here to Skip to main content
11,411,840 members (66,590 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
Anyone knows how to parse out a text file line by line and when two pipe signs found to be adjacent to each other then the program would place a string (for example the qord Null) in between. I am using the following code to pen and read the text file to begin with:
 using (StreamReader readFile = new StreamReader(tmpFilename.FullName.ToString()))
string line = null;
    while ((line = readFile.ReadLine()) != null)
             // Code here....process out certain fields in each line }

Need to know the best appraoch to do so without impacting performance. Thanks.
Posted 24-Jul-12 8:30am
Edited 24-Jul-12 9:35am
(no name)46.1K
Wes Aday at 24-Jul-12 14:19pm
Anything wrong in string.Replace("||", "|Null|"); ?
Member 8714829 at 24-Jul-12 15:20pm
That works I've also thought about it but wondered if it would impact performance (having to replace any occurance within each line! I will try it, many thanks.
Wes Aday at 24-Jul-12 20:12pm
The string replacement will probably be a negligible performance impact compared to the reading of the file from disk.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 268
1 Sergey Alexandrovich Kryukov 200
2 Sascha Lefévre 170
3 ProgramFOX 130
4 Maciej Los 110
0 Sergey Alexandrovich Kryukov 8,955
1 OriginalGriff 7,158
2 Maciej Los 3,480
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 24 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100