毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

C#的FTP服务器软件系统的设计与实现(14)

时间:2017-04-28 09:26来源:毕业论文
{ 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] =


            {
                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#的FTP服务器软件系统的设计与实现(14):http://www.751com.cn/jisuanji/lunwen_5865.html
------分隔线----------------------------
推荐内容