On the server, the C drive is generally not allowed to create documents through the Web, unless you open the file in the permission settings and change it to another disk.
Public static void log (string MSG = "")
{
Try
{
String Path = "C: \ log.txt ";
// String Path = @ "C: \ log.txt ";
If (system. Io. file. exists (PATH) = false)
Using (system. Io. filestream writer = system. Io. file. Create (PATH ))
{
Writer. Close ();
}
Using (system. Io. streamwriter writer = system. Io. file. appendtext (PATH ))
{
Writer. writeline (system. datetime. now. tostring ("yyyy-mm-dd hh: mm: SS: ffff") + "->" + String. concat (MSG, environment. newline ));
Writer. Close ();
}
String Path = @ "D: \ log.txt ";
System. Io. streamwriter writer;
If (system. Io. file. exists (PATH) = false)
Writer = system. Io. file. createtext (PATH );
Else
Writer = system. io. file. appendtext (PATH); writer. writeline (system. datetime. now. tostring ("yyyy-mm-dd hh: mm: SS: ffff") + "->" + String. concat (MSG, environment. newline ));
Writer. Close ();
}< br> catch (system. Exception ex)
{< br> int I = 00;
}< BR >}