www.pudn.com > UDS1.1_51aspx.rar > Error.cs


using System; 
using System.Diagnostics; 
using System.IO; 
 
 
namespace UDS.Components  
{ 
	///  
	/// 错误处理函数,用于记录错误日志 
	///  
	public class Error { 
		//记录错误日志位置 
		private const string FILE_NAME = "c:\\udslog.txt"; 
 
		///  
		/// 记录日志至文本文件 
		///  
		/// 记录的内容 
		public static void Log(string message) { 
			if(File.Exists(FILE_NAME)) 
			{ 
				StreamWriter sr = File.AppendText(FILE_NAME); 
				sr.WriteLine ("\n"); 
				sr.WriteLine (DateTime.Now.ToString()+message); 
				sr.Close(); 
			} 
			else 
			{ 
				StreamWriter sr = File.CreateText(FILE_NAME); 
				sr.Close(); 
			} 
			 
				 
		} 
	} 
}