.NET에서 (C#은 구체적 임) 우리는 FileSystemWatcher
을 사용하여 모든 유형의 수정을 감지 할 수 있음을 알고 있습니다.FileSystemWatcher를 사용하여 파일을 볼 때 파일을 삭제할 수 있습니까?
public void MessageFileWatcher(string Path, string FileName)
{
FileSystemWatcher Watcher = new FileSystemWatcher();
Watcher.Path = Path;
Watcher.Filter = FileName;
Watcher.NotifyFilter = NotifyFilters.LastWrite;
Watcher.Changed += new FileSystemEventHandler(OnChanged);
Watcher.EnableRaisingEvents = true;
}
하지만 파일을 감시하고 잠시 후 파일을 삭제하고 싶습니다.
정확합니다. FileSystemWatcher
클래스는 항상 수정을 찾습니다 ... 그리고 그 특정 파일을 삭제하려면 예외가 발생합니까?
시도해보고 알아 보시겠습니까? – jason