나는 여러 폴더를 모니터링하기 위해 FileSystemWatcher
을 사용하고 있습니다. 변경 이벤트가 발생하면 변경된 파일의 파일 이름을 가져 오려고합니다. e.Name 또는 e.FullPath를 사용할 때 감시자가 폴더를 모니터링하므로 폴더 경로가 표시됩니다.폴더의 파일 시스템 감시자이며 파일 이름을 얻는 중
파일 이름을 가져 오는 방법이 있습니까?
코드 : 그것의와 쳐들의 배열.
watchers[_Idx] = new FileSystemWatcher();
watchers[_Idx].Path = row.Cells[0].Value.ToString();
watchers[_Idx].IncludeSubdirectories = true;
watchers[_Idx].NotifyFilter = NotifyFilters.LastWrite |
NotifyFilters.DirectoryName | NotifyFilters.FileName |
NotifyFilters.Size;
watchers[_Idx].Changed += new FileSystemEventHandler(SyncThread);
watchers[_Idx].Created += new FileSystemEventHandler(SyncThread);
watchers[_Idx].Renamed +=new RenamedEventHandler(SyncThread);
watchers[_Idx].EnableRaisingEvents = true;
FileSystemWatcher 및 해당 속성을 초기화하는 코드를 표시하십시오. – Steve
디렉토리 변경 사항을 알지 않으려면 NotifyFilters.DirectoryName –