hi guyes,
my need is to read the next line data and check the particular character(i.e ;) in that data from file when i read the current line
without consuming next line by streamreader();
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 7, 2013, 11:41 PM
hi,
To do this you have to read whole file first using File.ReadAllText methods
try..
string text = System.IO.File.ReadAllText(@"D:\textfile.txt");
var allText = text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
for (var i = 0; i <= allText.Count(); i++)
{
string line = allText[i];
string nextline = allText[i + 1]; // put here validation if it is not exceed the array limit.
//do your code.
}
hope this will help you.
VulpesPosted Jul 7, 2013, 11:29 AM
using (StreamReader sr = new StreamReader("atul.txt"))
{
int i;
int c = (int)';';
string line = null;
while ((i = sr.Peek()) > 0)
{
if (i == c) break;
line = sr.ReadLine();
// code to insert line data into database
}
}
Iftikar HussainPosted Jul 7, 2013, 9:12 AM
10029365,20130701,dbt,ep,manfee
;MGFEE:Management Fee
OR
10029365,20130701,dbt,ep,manfee;MGFEE:Management Fee
Regards,
Iftikar
Mai Hu NaPosted Jul 7, 2013, 6:34 AM
VulpesPosted Jul 5, 2013, 9:40 AM
If the '; 'will only appear as the first character of a line, you could also use line.StartsWith(";").
Mai Hu NaPosted Jul 5, 2013, 9:18 AM
Iftikar HussainPosted Jul 5, 2013, 8:31 AM
Can you provide your code?
Regards,
Iftikar