draghuna
August 29th, 2006, 03:46 PM
I have the following code to in my application but when I try to run the application I am getting the error
"The process cannot access the file "BATCHFIle.bat" because it is being used by another process"
//Function 1
public void Function1()
{
StreamReader strmReader = new StreamReader(tempBatchFileName);
StreamWriter strmWriter = new StreamWriter(BatchFileName);
while(strmReader.Peek() != -1)
{
string currentLine = strmReader.ReadLine();
strmWriter.WriteLine(currentLine);
}
strmReader.Close();
strmWriter.Close();
}
//Function2
public string Function2()
{
System.IO.StreamReader strm = System.IO.File.OpenText(BatchFileName);
while(strm.Peek() != -1)
{
console.WriteLine(strm.ReadLine());
}
return "test";
}
Any idea whats causing this issue. I am closing it in the first Function but still not able to access it.
"The process cannot access the file "BATCHFIle.bat" because it is being used by another process"
//Function 1
public void Function1()
{
StreamReader strmReader = new StreamReader(tempBatchFileName);
StreamWriter strmWriter = new StreamWriter(BatchFileName);
while(strmReader.Peek() != -1)
{
string currentLine = strmReader.ReadLine();
strmWriter.WriteLine(currentLine);
}
strmReader.Close();
strmWriter.Close();
}
//Function2
public string Function2()
{
System.IO.StreamReader strm = System.IO.File.OpenText(BatchFileName);
while(strm.Peek() != -1)
{
console.WriteLine(strm.ReadLine());
}
return "test";
}
Any idea whats causing this issue. I am closing it in the first Function but still not able to access it.