string N0 = "F" + F0.ToString().Trim();
using (StreamReader sr = new StreamReader(@"c:/dp2/inp.txt", Encoding.Default))
{
while ((line = sr.ReadLine()) != null)
{
{
using (StreamWriter sw = new StreamWriter(@"c:/dp2/"+N0+".txt"))
{
sw.WriteLine(line);
}
if (C0 % 5000 == 0)
{
F0++;
N0 = "F" + F0.ToString().Trim();
}
C0++;
}
}
}
what to adjust to get what I expect to have?
string N0 = "F" + F0.ToString().Trim();
using (StreamReader sr = new StreamReader(@"c:/dp2/inp.txt", Encoding.Default))
{
while ((line = sr.ReadLine()) != null)
{
{
using (StreamWriter sw = new StreamWriter(@"c:/dp2/" + N0 + ".txt"))
{
sw.AutoFlush = true;
sw.WriteLine(line);
}
if (C0 % 8000 == 0 && C0 >= 8000)
{
F0++;
N0 = "F" + F0.ToString().Trim();
}
C0++;
}
}
}
Open in new window
This second solution is not COMPLITE, but will be better. I wrote it on the fly also in C#. You will need to add one more loop and counter for files.
Open in new window