우문현답에 감사드리며
1.0.0.0 폴더에 test.txt 파일을 삭제 시도 시 MessageBox.Show("경고")를 띄우려하는데
안되네요 ㅜㅜ
private FileSystemWatcher _fileSystemWatcher;
private void Run_Watcher()
{
_fileSystemWatcher = new FileSystemWatcher(Application.LocalUserAppDataPath);
_fileSystemWatcher.NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size;
_fileSystemWatcher.Changed += OnChanged;
_fileSystemWatcher.Created += OnCreated;
_fileSystemWatcher.Deleted += OnDeleted;
_fileSystemWatcher.Renamed += OnRenamed;
_fileSystemWatcher.Error += OnError;
_fileSystemWatcher.Filter = "*.txt";
_fileSystemWatcher.IncludeSubdirectories = true;
_fileSystemWatcher.EnableRaisingEvents = true;
}
private void btnFeileEvent_Click(object sender, EventArgs e)
{
Run_Watcher();
}
private static void OnDeleted(object sender, FileSystemEventArgs e)
{
MessageBox.Show("OnDeleted: " + e.FullPath);
}
[최초 등록일: ]
[최종 수정일: 4/18/2023]