c*o 发帖数: 70 | 1 Many users will write to the same logfile, how can I make sure there is no
conflict when there are some concurrent access? I can't find a method to check
if the file is open or not.
Would you please add some sample code based on the following code? Thank you
so much!
StreamWriter sw=File.AppendText (sLogFile);
sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText);
sw.Flush ();
sw.Close (); |
k****i 发帖数: 1072 | 2 when you create or open the file
check
【在 c*o 的大作中提到】 : Many users will write to the same logfile, how can I make sure there is no : conflict when there are some concurrent access? I can't find a method to check : if the file is open or not. : Would you please add some sample code based on the following code? Thank you : so much! : StreamWriter sw=File.AppendText (sLogFile); : sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText); : sw.Flush (); : sw.Close ();
|
e*********s 发帖数: 200 | 3 open it exclusively for write;
or creating a reader/writer threading model to handle concurrency conflicts...
this is a very typical situation
check
【在 c*o 的大作中提到】 : Many users will write to the same logfile, how can I make sure there is no : conflict when there are some concurrent access? I can't find a method to check : if the file is open or not. : Would you please add some sample code based on the following code? Thank you : so much! : StreamWriter sw=File.AppendText (sLogFile); : sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText); : sw.Flush (); : sw.Close ();
|
G**T 发帖数: 388 | 4
conflicts...
hehe,
VB .NET has eventlog class, u can use it to write system log or ur own log
files.
you
【在 e*********s 的大作中提到】 : open it exclusively for write; : or creating a reader/writer threading model to handle concurrency conflicts... : this is a very typical situation : : check
|