Hi.
In my application I write errors which may occur to text file like this:
using(StreamRea der sw = new SteamReader(err ors.txt, true))
{
sw.WriteLine("E rror message here");
}
Sometimes, the program says that it cannot open "errors.txt " because it is being used by another process. The only process that might be using it is my application. So basically it's a file lock problem.
Question: If I use the StreamReader inside a "using" statement, is it necessary to call "Close()" it after I call "WriteLine( )"?
Or if you know of a better approach, please suggest.
Thanks.
In my application I write errors which may occur to text file like this:
using(StreamRea der sw = new SteamReader(err ors.txt, true))
{
sw.WriteLine("E rror message here");
}
Sometimes, the program says that it cannot open "errors.txt " because it is being used by another process. The only process that might be using it is my application. So basically it's a file lock problem.
Question: If I use the StreamReader inside a "using" statement, is it necessary to call "Close()" it after I call "WriteLine( )"?
Or if you know of a better approach, please suggest.
Thanks.
Comment