Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 13811
글쓴 사람
guest
홈페이지
첨부 파일
 

우문현답에 감사드리며
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]


비밀번호

댓글 작성자
 



2023-04-18 07시50분
c:\temp 디렉터리로 해놓고 테스트해도 마찬가지인가요? 딱히 안 될 이유가 없는데요, Application.LocalUserAppDataPath 경로를 출력해 보시고 정확히 그 디렉터리에서 테스트한 것인지 확인해 보세요.
정성태
2023-04-18 07시56분
[guest] 이렇게 빨리 감사드립니다^^; 항상 대안을 제시해주시네요 c:\temp
[guest]

... 46  47  48  49  50  51  52  53  54  55  [56]  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
1288박주만7/8/201431110C# 서비스 기반 데이터베이스(mdf) & InstallShield Limited Edition 설치 및 배포 [2]파일 다운로드1
1287김용환7/8/201428972오라클 db 사용관련 문의입니다. [4]파일 다운로드1
1286C#조으다7/8/201418904WebBrowser 공유기 관리 웹 페이지 인증 [3]
1285C#조으다7/5/201419195IE DocumentComplete 이벤트가 발생되지 않습니다. [2]
1284(non...7/4/201419578(글쓴이의 요청으로 삭제합니다.) [3]
1283김영대7/3/201422412안녕하십니까 정성태님 죄송하지만 SmartClient 에 관한 질문이 있습니다. [9]
1282(non...7/2/201419335(글쓴이의 요청으로 삭제합니다.) [2]
1281(non...7/1/201420523(글쓴이의 요청으로 삭제합니다.) [4]
1280동동이6/25/201420183안녕하세요. ocx의 비동기 또는 쓰레드에서 호출 [1]
1279(non...6/23/201420505(글쓴이의 요청으로 삭제합니다.) [17]
1278이상식6/19/201421906.net DLL 내 자바스크립트를 수정 또는 재정의 할 수 있을까요? [3]
1277김솔지6/18/201418207silverlight에서 datagrid, listbox질문이여 [2]
1276정우석6/16/201417919쿠키 [1]
1274김솔지6/10/201422322배포 페이지 url을 얻고 싶습니다. [8]
1272이훈모6/7/201416901정말 어려운 상황에 직면했습니다. [1]
1270Jong...6/2/201427506C#과 C++을 이용한 Image 처리. [13]
1269김아영5/29/201417973InitializeComponent 함수 호출 지연 현상 [5]
1268솔솔5/27/201417363smart client [1]
1266김솔지5/22/201419821clickonce 수정에 대해 알고싶습니다. [2]
1265이은아5/22/201424347DataGridView 헤더를 두줄이상으로 하고싶습니다. [1]파일 다운로드1
1264김인호5/18/201423153소스코드 및 예제그림 zip 파일 [1]
1263이영종5/15/201419857159페이지 오타인것 같습니다 [5]
1262(non...5/4/201420645(글쓴이의 요청으로 삭제합니다.) [10]
1261이근주5/4/201418151다시 한번 질문드릴께요. [2]
1259이근주5/1/201418113도서 오류인 것 같네요.. [1]
1258최세정4/28/201420713안녕하세요~php module 오류로 고민하다가 여기까지 왔네요..ㅜㅜ [2]
... 46  47  48  49  50  51  52  53  54  55  [56]  57  58  59  60  ...