{
                string[] Item = new string[4];
                Item[0] = Log["ErrorSource"].ToString();
                Item[1] = ((DateTime)Log["DateTime"]).ToString(ApplicationSettings.DateTimeFormat);
                Item[2] = Log["Exception"].ToString();
                Item[3] = Log["Message"].ToString();
                lstExceptionList.Items.Add(new ListViewItem(Item));
            }
        }//清空日志列表

        void CancelSearch_Click(object sender, EventArgs e)
        {
            CancelSearch =
                MessageBox.Show("Are you sure to cancel the searching operation?", "Advanced FTP Server",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
        }//取消日志搜索
写入日志方法:
namespace AdvancedFTPServer
{
    internal enum LogSource
    {
        HTTP, FTP
    }

    internal class ApplicationLog
    {
        static FileStream LogStream;
        static StreamWriter Log;
        static string LogFilePath;
        internal static bool EnableLogging = true;

        [MethodImpl(MethodImplOptions.Synchronized)]
        internal static void Write(LogSource Source, Exception Ex)
        {
            if (Ex == null || !EnableLogging) return;
            if (Ex.InnerException != null) Ex = Ex.InnerException;

            try
            {
                if (!Directory.Exists(ApplicationSettings.DataPath + "Logs\\"))
                    Directory.CreateDirectory(ApplicationSettings.DataPath + "Logs\\");

                LogFilePath = ApplicationSettings.DataPath + "Logs\\LOG." + DateTime.Today.ToString("yyyy-MM-dd") + ".EXCEPTION";

                LogStream = new FileStream(LogFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
                Log = new StreamWriter(LogStream, Encoding.UTF8);
上一篇:造币机械生产车间信息管理系统分析与研究
下一篇:C#的家庭理财系统软件设计+ER图

基于Apriori算法的电影推荐

PHP+IOS的会议管理系统的设计+ER图

数据挖掘在电子商务中的应用

数据挖掘的主题标绘数据获取技术与实现

基于PageRank算法的网络数据分析

基于神经网络的验证码识别算法

基于网络的通用试题库系...

医院财务风险因素分析及管理措施【2367字】

中国学术生态细节考察《...

C#学校科研管理系统的设计

神经外科重症监护病房患...

承德市事业单位档案管理...

国内外图像分割技术研究现状

公寓空调设计任务书

志愿者活动的调查问卷表

10万元能开儿童乐园吗,我...

AT89C52单片机的超声波测距...