K
Kuznetsov Dmitriy
Hello, I try to write message to log file
(I take code from MSDN samples)
but simple program:
---
using System.IO;
using System.Diagnostics;
class Test
{
public static void Main(string[] args)
{
string logFile = "Log.txt";
if(!File.Exists(logFile))
File.Create(logFile);
StreamWriter logStream = File.AppendText(logFile);
TextWriterTraceListener logListener =
new TextWriterTraceListener(logStream);
}
}
---
throws an exception:
System.IO.IOException: The process cannot access the file "Log.txt"
because it is being used by another process.
can anybody explain to me what wrong?
(I take code from MSDN samples)
but simple program:
---
using System.IO;
using System.Diagnostics;
class Test
{
public static void Main(string[] args)
{
string logFile = "Log.txt";
if(!File.Exists(logFile))
File.Create(logFile);
StreamWriter logStream = File.AppendText(logFile);
TextWriterTraceListener logListener =
new TextWriterTraceListener(logStream);
}
}
---
throws an exception:
System.IO.IOException: The process cannot access the file "Log.txt"
because it is being used by another process.
can anybody explain to me what wrong?