[C#] 监控文件或目录的变化 →→→→→进入此内容的聊天室

来自 , 2019-09-24, 写在 C#, 查看 101 次.
URL http://www.code666.cn/view/a6640ad0
  1. public void StartMonitor(string path)
  2. {          
  3.         FileSystemWatcher watcher = new FileSystemWatcher();
  4.         watcher.Path = path;
  5.  
  6.         watcher.NotifyFilter = NotifyFilters.FileName;
  7.         // Only watch pdf files.
  8.         watcher.Filter = "*.pdf";
  9.         watcher.Created += new FileSystemEventHandler(OnChanged);
  10.         watcher.EnableRaisingEvents = true;
  11. }
  12.  
  13. // Event handler for when a  file is created in the watched folder
  14. private void OnChanged(object source, FileSystemEventArgs e)
  15. {
  16.         string word = DocumentUtility.ConvertPdfToDoc(e.FullPath);
  17. }
  18. //csharp/196

回复 "监控文件或目录的变化"

这儿你可以回复上面这条便签

captcha