Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 11376
글쓴 사람
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)
1212조광훈2/13/201416283ISAPI 필터에서 커스텀 헤더 정보 추가 [1]파일 다운로드1
1211조광훈2/12/201420364isapi 필터 로드 오류 [2]
1208박지호2/9/201424433[오타] 시작하세요 C# 프로그래밍 p.267 ~ 350 [1]
1207임동찬2/5/201418631Web페이지에서 .net application 실행시키는 방법 [3]
1206신지환2/3/201419942visual sourcesafe(internet) 체크인 에러 [1]
1205박지호2/2/201422288[오타] 시작하세요 C# 프로그래밍 p.199 ~ 202 [1]
1204김태훈1/27/201433285Windows Service 오류 문의입니다. [2]
1203박지호1/26/201423937[오타] 시작하세요 C# 프로그래밍 p.131, 157, 180 [1]
1202이창주1/24/201425603[질문] Windows Error Reporting [8]
1201김나리1/21/201418545[시작하세요 C# 프로그래밍] 비동기 호출 [1]
1200박지호1/19/201423667[오타] 시작하세요 C# 프로그래밍 p.76 [1]
1199윤종현1/9/201419240p654 의 비동기 관련 설명 [3]
1198초이1/4/201418955웹서비스 WSDL 생성및 프록시 클래스 생성 관련 질문입니다. [1]
1196박현수1/2/201417668[WCF] Client 호출 방법 [2]
1195박현수12/23/201317621[WCF] 클라이언트의 호출실패(IIS이용) [4]파일 다운로드1
1191박주만12/18/201324649C++ Dll 에서 C# 의 PictureBox이미지 변경문제 [1]
1193박주만12/19/201318686    답변글 [답변]: C++ Dll 에서 C# 의 PictureBox이미지 변경문제 [2]파일 다운로드1
1190정진호12/10/201316804비동기로 실행할수 있도록 Custom Attribute 를 만들고 싶습니다. [1]
1189Youn...12/10/201317099책을 사기전에 궁금한것이 있습니다. [1]
1188이민석12/5/201318449ocx 를 C#에서 마샬링관련 질문입니다.. [2]파일 다운로드1
1187이성환12/3/201319661WPF WebBrowser control의 자식 창이 close 되기 전 Navgate 재호출 문제 [2]파일 다운로드1
1186박종혁12/2/201317642책의 예제 중에 result 변수가 할당 되었지만 사용되지 않았다고 오류가 납니다!! [1]
1185박은희11/27/201320741멀티바이트로 개발한 프로그램을 유니코드로 변경시 쉽게 처리 하는법 [2]파일 다운로드1
1183박현수11/20/201317575WCF에서 web.config appsetting 읽기 [1]
1184박현수11/20/201318449    답변글 [답변]: WCF에서 web.config appsetting 읽기 [3]파일 다운로드1
1182유창우11/16/201327477자마린이 궁금... [8]
... 46  47  48  49  50  51  52  53  54  55  56  57  [58]  59  60  ...