valentinemhlanga
asked on
Count Number of Lines in text file c# and also write to the same file .
hello ,
I am trying to populate a field in my text file and it needs the number of records in the text file, meaning the lines.
each time I try to use the code below , I get an error saying that the file is being used as I am writting other records to it .
int count = 0;
string line;
TextReader reader1 = new StreamReader(@"\sqlfile.tx t");
while ((line = reader1.ReadLine()) != null)
{
count++;
}
reader.Close();
I am trying to populate a field in my text file and it needs the number of records in the text file, meaning the lines.
each time I try to use the code below , I get an error saying that the file is being used as I am writting other records to it .
int count = 0;
string line;
TextReader reader1 = new StreamReader(@"\sqlfile.tx
while ((line = reader1.ReadLine()) != null)
{
count++;
}
reader.Close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.