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.Tasks;
using System.Windows.Forms;
namespace FileWatcher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
fileSystemWatcher.Path = txtPath.Text.Trim();
fileSystemWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.DirectoryName;
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.EnableRaisingEvents = true;
}
private void fileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Changed:" + e.FullPath);
}
private void fileSystemWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Created:" + e.FullPath);
}
private void fileSystemWatcher_Deleted(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Deleted:" + e.FullPath);
}
}
}
C# FileSystemWatcher的使用
最新推荐文章于 2024-08-24 20:51:21 发布
关键词由CSDN通过智能技术生成