Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 16062
글쓴 사람
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]

... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
5495Natie5/13/202115458객체를 생성과 동시에 초기화 하는 방법 [1]
5494지예예지5/13/202117677비동기 코드 흐름이 궁금합니다! [2]
5493xing...5/6/202115195xing api XQCSPAT00600 질문입니다 [4]파일 다운로드1
5492한예지 donator5/5/202115196FromCurrentSynchronizationContext 관련 코드 질문있습니다! [2]
5491조우성5/4/202121088WinForm과 WPF의 성능차이 비교한 자료가 있을까요? [4]
5490한예지 donator5/3/202117199UI 스레드의 Invoke 질문있습니다. [4]
5489저누4/28/202118059시작하세요 C# 9.0, 225페이지 구조체 관련 질문드립니다. [2]
5488종범4/27/202118163C# 비동기 함수 async, await 와 Task의 관계에 대해 질문 드립니다. [6]
5487진우4/27/202117068C# 엑셀 자동화 성능 향상 문의 [2]
5486지나가던...4/26/202117464닷넷 구현 코드 관련 질문 [2]
5485이재원4/17/202117922교재 315페이지 내용 질문 [3]
5484Syong4/16/202121596윈폼 기반의 응용프로그램 dll 참조와 32,64bit 빌드 관련 문의 [4]
5483한예지 donator4/15/202116621익명 형식과 var 관계 질문 있습니다. [2]
5482질문4/13/202118434WPF를 위한 MVVM toolkit 선택과 관련한 문의드립니다. [4]
5480한예지 donator4/5/202120500GetHashCode 질문있습니다! [2]
5479한예지 donator4/4/202117945Equals를 닷넷에서 어떻게 구현했는지 보고 싶을 떄는 어떻게 해야 될까요? [2]
5478갑자기C#3/23/202121210C# Winform에서 TextBox없이 입력 받을 수 있나요? [7]
5477달팽이3/18/202117153c# 도형을 그린후 편집하는 방법이 궁금합니다. [2]파일 다운로드1
5475dimo...3/2/202117342POH가 .NET 5에 추가된 것으로 알고 있습니다. POH가 유용한 경우는 어떤 경우가 있을까요? [1]
5474Syong2/26/202117897사용자 지정 컨트롤 생성시 Invalidate, Update, Refresh의 차이점 [2]
5473한예지 donator2/25/202116122디자인 타임이 뭔지 궁금합니다!! [5]
5472dimo...2/24/202119212등록하지 않고 ocx를 사용하는 `키움`관련 포스팅을 따라가다 질문드립니다. [9]
5471남산2/21/202115665MarshalDirectiveException 에 대한 질문입니다. [1]
5470한예지 donator2/7/202115971yield 질문있습니다!! [2]
5469유호성2/6/202115847Parallel + Task.Run 동시 실행 환경에서 간헐적으로 Task.Run()에서 null이 리턴됩니다. [3]파일 다운로드1
5467hero...2/4/202116307실행 환경에 따른 Thread.Sleep 딜레이 차이 질문 [8]
... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...