//log content, file namePrivate stringWritelog (stringValuestringname) { stringstrpath =""; Try{strpath= System.Web.HttpContext.Current.Server.MapPath ("Log"); } Catch { } if(strpath = ="") strpath =Application.startuppath; FileStream LogFile=NULL; stringStrdate =DateTime.Now.Year.ToString (); Strdate+="-"+DateTime.Now.Month.ToString (); Strdate+="-"+DateTime.Now.Day.ToString (); if(! Directory.Exists (strpath+"\\log")) Directory.CreateDirectory (strpath+"\\log"); if(! Directory.Exists (strpath +"\\log\\"+strdate)) Directory.CreateDirectory (strpath+"\\log\\"+strdate); strpath= strpath +"\\log\\"+ Strdate +"\\"+ name +". txt"; if(LogFile = =NULL) LogFile=NewFileStream (strpath, FileMode.OpenOrCreate, FileAccess.ReadWrite, fileshare.readwrite); stringStrline=Environment.NewLine; stringStrtime=datetime.now.tostring ("HH:mm:ss"); stringstr =""; if(Name! ="Upbeifensql"&& Name! ="Upedsql"&& Name! ="Lianjisql") Str= Strtime +StrLine; STR+ = value +StrLine; if(Name! ="Upbeifensql"&& Name! ="Upedsql"&& Name! ="Lianjisql") Str+="*********************************************************************************************************** ******************"+StrLine; if(Name = ="Upbeifensql"|| Name = ="Upedsql"|| Name = ="Lianjisql") {Compressionhelper compress=NewCompressionhelper (); STR=compress.compresstostring (str); STR+=StrLine; } byte[] bytes =System.Text.Encoding.Default.GetBytes (str); Logfile.position=logfile.length; Logfile.write (Bytes,0, (int) bytes. Length); Logfile.close (); LogFile=NULL; returnstrpath; }
C # Write Log method