Microsoft MVP성태의 닷넷 이야기
fileSystemWatcher 이벤트 관련 질문입니다 [링크 복사], [링크+제목 복사],
조회: 11306
글쓴 사람
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)
5074진우10/28/201814217C# 생성과 동시에 초기화 하는 코드 문의 [2]
5073돌고래10/27/201814273c# 공부 방향 질문 드립니다. [3]
5072엔벌잉10/24/201814378C# textbox, button질문입니다! [4]파일 다운로드1
5071엔벌잉10/23/201815352C#윈도우폼 질문입니다!! [2]
5070진우10/17/201815354Visual Studio 서비스팩과 업데이트 차이 문의 [2]
5069감자10/12/201816152빌드 구성을 재설정하는 방법이 있을까요? [1]파일 다운로드1
5068누오10/10/201814781ASP Core 2.0 에서 dll안에 있는 뷰 읽어들이는 방법? [1]
5067김정민10/5/201814983다른 윈도우가 깨지는 현상을 막을 수 있을까요 [3]
5066로니브10/4/201815741ASP.NET MVC에서 View 파일 숨기는법? 보안처리 하는법? 관련 질문.. [1]
5065키모10/1/201817224문자 질문입니다. [3]
5064로니브10/1/201816584클래스 라이브러리에서 .cshtml파일을 추가하는 방법은 없나요? [3]
5063진우9/28/201815443ADO.net 과 Entity Framework 차이 문의 [2]
5062테스트9/27/201815966C# import file 의 구조체 배열 선언 및 호출에 대해 문의. [3]
5061안녕하세요9/13/201816159c# 프로그래밍 관련 문의 [1]
5060임민재9/8/201815226c# install 파일 생성 시 문제가 발생하였습니다 [1]파일 다운로드1
50599/7/201814703Winform TextBox 포커스 유지하는 방법 질문 [파일첨부] [1]파일 다운로드1
50589/5/201818935Winform TextBox 포커스 유지하는 방법 질문 [3]
5056박종윤8/30/201817653c# dll을 C++에서 사용 시 event 호출 [4]파일 다운로드1
5055초보자8/29/201816711asp.net 에서 다른 서버의 iis를 stop하는 batch file을 실행시키는데 동작하지 않습니다. [5]
5054사도신8/29/201815225[wpf] textbox insert overite 모드시에 [4]파일 다운로드1
5053엿장수8/26/201814246directshow filter 에서의 IMediaSample 의 시간에대한질문입니다 [1]
5052오명현8/26/201814825Tcp소켓 실습 Exeption 도와주세요! [4]파일 다운로드1
5049오명현8/23/201814323책 477페이지 내용 중 이해가 안가는 부분이 있어 질문드립니다. [1]
5048오명현8/23/201813976포트 관련 질문 하나더 있습니다. [1]
5047오명현8/22/201814811포트가 없을 경우를 가정한 내용에 대해 질문이 있습니다. 책468p. [1]
5046엿장수8/22/201814664다이렉트쇼 필터 추가하는데 [2]
... 31  32  [33]  34  35  36  37  38  39  40  41  42  43  44  45  ...