Create a folder in the application, name it errorlog, and then execute the following program
Code
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. IO;
Namespace consoleapplication1
{
Class Program
{
Static void main (string [] ARGs)
{
// Create an error file directory
String Path = directory. getcurrentdirectory ();
Directoryinfo A = directory. getparent (PATH );
A = directory. getparent (A. fullname );
String [] dirs = directory. getdirectories (A. fullname, "errorlog ");
String Pa = dirs [0] + "\" + datetime. Now. year. tostring () + "\" + datetime. Now. Month. tostring ();
String log = pa + "\" + datetime. Now. tow.datestring () + ". txt ";
/* Check and create a folder */
If (! Directory. exists (PA ))
{
Directory. createdirectory (PA );
}
/* Check and create a log record */
If (! File. exists (log ))
File. Create (log). Close ();
// Write the following error information to the directory
Using (streamwriter W = file. appendtext (log ))
{
W. writeline ("error time: {0}", "123 ");
W. writeline ("__________________________");
W. Flush ();
W. Close ();
}
}
}
}