Re: .NET StreamWriter Error
I think you should put in Funciton1, before you close the streamwriter, strmWriter.Flush();
This might not solve your problem, but it's a good programming to put it there.
Re: .NET StreamWriter Error
In Function2, you doesn't close the strem. Genraly, it is recommended to use using statement to work with stream. See the example.
Code:
public void Function1()
{
using (
StreamReader strmReader = new StreamReader(tempBatchFileName);
StreamWriter strmWriter = new StreamWriter(BatchFileName);
){
while(strmReader.Peek() != -1)
{
string currentLine = strmReader.ReadLine();
strmWriter.WriteLine(currentLine);
}
}
But don't forget: the file can be opened (and holded) by totaly different process like Notepad. Also keep in mind: always Dispose() any object which is using external resources (like file). Using statement does it for you, but keep it in mind.