Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 13153
글쓴 사람
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)
1218김형진2/25/201420035안녕하세요. window azure에 대해서 질문이 있어서 문의 드립니다 [4]
1217(non...2/23/201420554(글쓴이의 요청으로 삭제합니다.) [1]
1215아리수2/20/201424048C# 공부하면서 WPF에 대한 질문. [2]
1214조광훈2/20/201422053IIS8 응용프로그램 풀 관련 질문 드립니다. [2]파일 다운로드1
1213김태훈2/17/201419299가상화 프로그램 질문입니다. [1]파일 다운로드1
1212조광훈2/13/201417925ISAPI 필터에서 커스텀 헤더 정보 추가 [1]파일 다운로드1
1211조광훈2/12/201422072isapi 필터 로드 오류 [2]
1208박지호2/9/201426091[오타] 시작하세요 C# 프로그래밍 p.267 ~ 350 [1]
1207임동찬2/5/201420418Web페이지에서 .net application 실행시키는 방법 [3]
1206신지환2/3/201421196visual sourcesafe(internet) 체크인 에러 [1]
1205박지호2/2/201424232[오타] 시작하세요 C# 프로그래밍 p.199 ~ 202 [1]
1204김태훈1/27/201435093Windows Service 오류 문의입니다. [2]
1203박지호1/26/201425837[오타] 시작하세요 C# 프로그래밍 p.131, 157, 180 [1]
1202이창주1/24/201427573[질문] Windows Error Reporting [8]
1201김나리1/21/201420374[시작하세요 C# 프로그래밍] 비동기 호출 [1]
1200박지호1/19/201425576[오타] 시작하세요 C# 프로그래밍 p.76 [1]
1199윤종현1/9/201420741p654 의 비동기 관련 설명 [3]
1198초이1/4/201420275웹서비스 WSDL 생성및 프록시 클래스 생성 관련 질문입니다. [1]
1196박현수1/2/201418921[WCF] Client 호출 방법 [2]
1195박현수12/23/201319170[WCF] 클라이언트의 호출실패(IIS이용) [4]파일 다운로드1
1191박주만12/18/201326196C++ Dll 에서 C# 의 PictureBox이미지 변경문제 [1]
1193박주만12/19/201320210    답변글 [답변]: C++ Dll 에서 C# 의 PictureBox이미지 변경문제 [2]파일 다운로드1
1190정진호12/10/201318312비동기로 실행할수 있도록 Custom Attribute 를 만들고 싶습니다. [1]
1189Youn...12/10/201318529책을 사기전에 궁금한것이 있습니다. [1]
1188이민석12/5/201319857ocx 를 C#에서 마샬링관련 질문입니다.. [2]파일 다운로드1
1187이성환12/3/201321157WPF WebBrowser control의 자식 창이 close 되기 전 Navgate 재호출 문제 [2]파일 다운로드1
... 46  47  48  49  50  51  52  53  54  55  56  57  [58]  59  60  ...