Click here to Skip to main content
12,633,764 members (32,415 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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
Updated 24-Jul-12 9:35am
lewax0046.1K
v2
Comments
Wes Aday 24-Jul-12 14:19pm
   
Anything wrong in string.Replace("||", "|Null|"); ?
Member 8714829 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 24 Jul 2012
Copyright © CodeProject, 1999-2016
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