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

... 31  32  33  34  35  36  37  [38]  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
4945김성대1/26/201817067비동기 질문입니다. [1]파일 다운로드1
4944popo1/25/201816239[삭제] 스레드 안에서 Window Visibility 변경시 DialogResult 오류 질문
4943김성대1/22/201817688FromAsync 질문입니다. [1]
4942박현일1/19/201818725WPF 공부중 모르는 문법이 있어서요~^^; [2]
4941김성대1/18/201817643비동기예약어 실행오류관련입니다. [1]
4940plzh...1/10/201818362webbrowser2 를 이용한 sns 로그인 구현 관련 문의 [2]
4939이성일1/4/201820341ClickOnce 배포 후 업데이트 시 발생하는 오류에 대해 질문 드립니다. [2]
4938김성대1/3/201817930채팅 프로그램관련 질문입니다. [9]파일 다운로드1
4937Ques...1/3/201819714C# CPU 사용량 한계치 늘리는 방법 [2]
4936무개1/3/201816868책 내용 인용하는 것에 관한 질문이있습니다. [1]파일 다운로드1
4935몬난아12/28/201719672IIS 및 ASP.NET 이 서버에서의 동작방식? [2]
4934Ques...12/26/201731056C# 해상도에 따른 자동 사이즈 조절방법이 궁금합니다. [3]
4933Kay12/15/201717210C# VS 버전 에러 질문 드립니다. [1]파일 다운로드1
4932정환나라12/13/201717617vs2013에서 빌드한 com 컨트롤 객체를 닷넷 2.0에서 사용하려 합니다 [4]
4931Arvid12/12/201717446Visual Studio 2012 c# using문 참조 에러 [5]파일 다운로드1
4929김성대12/8/201716440app.config에 관한질문입니다. [1]
4928김성대12/7/201717068SQL Server 설치에러에 대한 질문입니다. [1]파일 다운로드1
4926heyh...12/6/201716388[삭제] ContextSwitchDeadlock????
4925ho12/5/201716486[삭제] WebBrowser로 드롭박스 로그인 페이지 탐색 시 발생한 문제에 대해 질문 올립니다.파일 다운로드2
4924몽중언12/3/201717033C# 디버깅 모드에서만 DB Insert가 되는 현상 질의 [6]
4923고요한11/23/201717476파일 확장자에 연결된 프로그램을 등록하는 방법에 대한 질문입니다. [2]
4922박성훈11/23/201718962시작하세요! C# 7.1 학습 방법 [3]
4921초보개발자11/20/201715572[삭제] 폼 사이즈 질문드립니다.
4920Ques...11/19/201715654IEnumerable 의 "지연된 평가" 에 관하여 질문드립니다. [2]파일 다운로드1
4919mskim11/16/201717231Split()을 이용하여 문자 구분 시 구분문자도 같이 저장하는 방법이 있나요? [2]
4917ho11/16/201716941WPF XAML 트리거 관련해 문의 드립니다. [3]
... 31  32  33  34  35  36  37  [38]  39  40  41  42  43  44  45  ...