MainForm.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 文件夹文件更新检测
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 文本框最多存储8M内容
        /// </summary>
        private void richTextBoxLengthCheck()
        {
            if (richTextBox.TextLength > 1024 * 1024 * 8)
            {
                richTextBox.Clear();
            }
        }

        /// <summary>
        /// 当更改指定 Path 中的文件和目录时发生。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                return;
            }
            richTextBoxLengthCheck();
            richTextBox.AppendText($"【{DateTime.Now:yyyy/MM/dd HH:mm:ss}】 {e.FullPath} 发生更改\r\n");
        }

        /// <summary>
        /// 当在指定 Path 中创建文件和目录时发生。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fileSystemWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            richTextBoxLengthCheck();
            richTextBox.AppendText($"【{DateTime.Now:yyyy/MM/dd HH:mm:ss}】 {e.FullPath} 创建\r\n");
        }

        /// <summary>
        /// 删除指定 Path 中的文件或目录时发生。
后面还有 78 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。