J
Jaga
Hi,
how can I read the same passage in a textfile several times?
I'm writing a little textgenerator. It reads lines from a file, replaces
the variables, and writes it in an other file. Some lines I have to read
several times and write them with other values.
What is wrong with this code:
using (StreamWriter swr = new StreamWriter(outPath))
{
using (StreamReader srd = new StreamReader(inPath,
System.Text.Encoding.Default, false))
{
long offset;
string line;
while ((line = srd.ReadLine()) != null)
{
switch (line)
{
case "XY...":
//mark the position
offset = srd.BaseStream.Position;
break;
case "YZ...":
if (...)
{
//jump back to the position
srd.BaseStream.Position = offset;
srd.DiscardBufferData();
}
break;
}
...
}
}
}
thanks
Jaga
how can I read the same passage in a textfile several times?
I'm writing a little textgenerator. It reads lines from a file, replaces
the variables, and writes it in an other file. Some lines I have to read
several times and write them with other values.
What is wrong with this code:
using (StreamWriter swr = new StreamWriter(outPath))
{
using (StreamReader srd = new StreamReader(inPath,
System.Text.Encoding.Default, false))
{
long offset;
string line;
while ((line = srd.ReadLine()) != null)
{
switch (line)
{
case "XY...":
//mark the position
offset = srd.BaseStream.Position;
break;
case "YZ...":
if (...)
{
//jump back to the position
srd.BaseStream.Position = offset;
srd.DiscardBufferData();
}
break;
}
...
}
}
}
thanks
Jaga