System.Diagnostics.StackFrame frame =NewSystem.Diagnostics.StackFrame (1); System.Reflection.MethodBase Method=frame. GetMethod (); stringNamspace =method. Declaringtype.namespace; stringClasname =method. Reflectedtype.name; stringMeth =method. Name; stringFullName = method. Declaringtype.fullname +"."+ Meth;
String path = AppDomain.CurrentDomain.BaseDirectory + "/log/";
System.Threading.ThreadPool.QueueUserWorkItem ((e) =
{
Try
{
if (! Directory.Exists (PATH))
{
Directory.CreateDirectory (path);
}
Path + = System.DateTime.Now.ToString ("yyyy-mm-dd") + ". txt";
if (! File.exists (PATH))
{
using (file.create (path)) {};
}
FileStream fs = new FileStream (path, filemode.append, FileAccess.Write);
StreamWriter SW = new StreamWriter (FS);
Sw. WriteLine ("----------------------------------" + System.DateTime.Now.ToString () + "------------------------------- -----\r\n\r\n Exception information is: \ r \ n "+ ex +" \ r \ n ");
Sw. WriteLine ("exception information");
Sw. Close ();
Fs. Close ();
}
Catch
{ }
});
C # obtains upper-layer invocation method information through reflection