监控文件或目录的变化的代码
作者:互联网
下面的代码段是关于监控文件或目录的变化的代码,应该能对码农有用。
public void StartMonitor(string path)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = path;
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
}
private void OnChanged(object source, FileSystemEventArgs e)
{
string word = DocumentUtility.ConvertPdfToDoc(e.FullPath);
}
标签:FileSystemWatcher,OnChanged,string,代码,watcher,void,监控,new,目录 来源: https://www.cnblogs.com/yeiye/p/15641635.html