Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 12634
글쓴 사람
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)
5108닷넷개발1/9/201916509thread 관련 질문 드립니다.. [4]
5107우코아1/4/201919721WPF에서 로딩중 이미지를 구현 - Project [5]파일 다운로드1
5106우코아1/3/201916915WPF에서 로딩중 이미지를 구현 - Source [1]
5104우코아1/1/201918881WPF에서 로딩중 이미지를 구현 [4]
5103이혜성12/31/20181911532bit .net 으로 만들어진 dll파일 [5]
5102돌고래12/18/201817624자료구조와 알고리즘 도서 관련 질문입니다. [4]
5101세퉁12/17/201815851안녕하세요 wpf 공부중인데 질문있습니다. [4]파일 다운로드1
5100돌고래12/16/201815139도서 추천 부탁드립니다. [1]
5099WPF12/12/201818082안녕하세요. WPF에서 UWP Control을 참조하려고 합니다. [3]파일 다운로드1
5097sdh12/10/201819265[c#] 라이선스 파일 만들기 질문 드립니다. [3]
5096거북이12/3/201814288프로젝트 구성을 참고할 만한 자료가 있을까요? [1]
5095한대현11/21/201814476안녕하세요 c# 설치 파일 빌드중 오류가 생겨서 문의 드려요 [1]파일 다운로드2
5094하주형11/20/201814543안녕하세요 C# using 예약어관련 질문드립니다. [1]
5093Medi...11/19/201818313안녕하세요. wpf Mediaelement 질문 있습니다. [3]
5092하주형11/17/201814716안녕하세요 c# 7.1책 스택관련 질문드립니다. [2]
5091아짱11/15/201816795UWP 개발중 질문이 있습니다. [3]
5090황윤하11/15/201820968c# Socket Server에 접근할 수 있는 client 개수 제한 [5]
5089문성운11/14/201818437uwp에서 TcpListener를 사용할 수 없나요? [5]
5088안중언11/10/201815306TCP 소켓 [1]파일 다운로드1
5084김광흠11/9/201817573사운드 파일 "filename.wav" 와 같은 특정 파일이 실행되는것을 감시하고 싶습니다. [3]
5083거북이11/4/201818112타입의 범위를 넘어서는 연산의 개념을 모르겠습니다. [4]
5082꾸엉11/1/201814990BCL 타입을 모아둔 곳이 있나요? [2]
5081꾸엉10/31/201815512C# 7.1 235p 질문입니다. [3]
5080WPF초보10/30/201817555[WPF] IsManipulationEnabled속성 설정시 Click이벤트 문의 [1]
5079jhp10/30/201817548이 소스에 API후킹 소스를 추가하고 싶은데 어떻게 해야될지 모르겠어요. [4]
5078꾸엉10/29/201815580C# 7.1 185~187p 질문입니다. [2]
... 31  [32]  33  34  35  36  37  38  39  40  41  42  43  44  45  ...