c# - Error occured While writing to the file -
I am creating the file for the first time after creating the file, I am going to open a file immediately, but this error shows up :
"Process" C: \ Project Works \ Websites 3 \ logs error \ error log \ error_Log_24_4_2014.txt 'because it is being used by any other process. " < / Blockquote>
What does this mean? For more writing work, how can I open a file? I have tried it with the following code.
FileName = String.Concat ("Error_Log_", DateTimeStamp + ext); If (file.exis (server.mappath ("~ / logs / error / error logs /" + filename)) (file (create server.mappath ("~ / logs error / error logs /" + filename));} // Here is an error, bottom line streamwire tw = new streamer (server.mappath ("~ / logs error / error logs /" + filename) is true); tw.WriteLine (""); Tw.Write ("\" "+ Tw.Write ("\" "Error Message +" \ ","); tw.Write ("\" \ ", \" \ "," "" + TransactVariable + "\" "); tw.Close ();
You do not need
File.Create because
StreamWriter will create a constructor file if it does not exist
This is what the MSDN documentation says:
A new installation begins with the StreamWriter specified encoding and the square for the specified file using the buffer size. If the file exists , Then it can be overwritten or added if the file does not exist, then this conts Ctor creates a new file.
Comments
Post a Comment