You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							37 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							37 lines
						
					
					
						
							1.5 KiB
						
					
					
				| using System; | |
| using System.IO; | |
| 
 | |
| namespace DyeingComputer.UserClass | |
| { | |
|     public class LogGing | |
|     { | |
|         public static void LogGingDATA(string dat) | |
|         { | |
|             string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录 | |
|             string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";//日志文件 | |
|             string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:"; | |
| 
 | |
|             if (Directory.Exists(logpath))//检查日志路径 | |
|             { | |
|                 if (!File.Exists(logPath))//检查日志文件并写入启动日志 | |
|                 { | |
|                     FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件  | |
|                     StreamWriter wr = new StreamWriter(fs);//创建文件 | |
|                     wr.WriteLine(Log_time + dat); | |
|                     wr.Close(); | |
|                 } | |
|                 else | |
|                 { | |
|                     FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); | |
|                     StreamWriter wr = new StreamWriter(fs);//创建文件 | |
|                     wr.WriteLine(Log_time + dat); | |
|                     wr.Close();                } | |
|             } | |
|             else | |
|             { | |
|                 DirectoryInfo directoryInfo = new DirectoryInfo(logpath); | |
|                 directoryInfo.Create();//创建日志路径 | |
|             } | |
|         } | |
|     } | |
| }
 | |
| 
 |