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

1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...
NoWriterDateCnt.TitleFile(s)
5658한예지 donator5/9/202214274교재 689, 690쪽(async/await) 질문입니다. [5]
5657C#초보5/8/202212719초보 단순 질문 입니다.,ㅠ [1]
5656부탁드립...5/6/20221500532bit dll 을 64bit dll 화 [2]
5655감사합니...5/5/202214814UI 스레드 관련 질문드립니다. [4]파일 다운로드1
5653고석주5/3/202212911첨부된 이미지처럼 dll 을 어떻게 추가해야 하는지 문의드립니다. [1]파일 다운로드1
5652감사합니...5/2/202211789프로그램 종료되면 리소스(관리, 비관리)는 알아서 해제 되나요? [2]
5651윤식4/26/202212823상속 구조 관련 질문드립니다. [8]
5650김기헌4/19/202212527WPF 리소스 관련 질문드립니다 [3]
5649주니어4/15/202211450ffmpeg 질문 있습니다! [2]
5648주니어개...4/13/202212116컴파일된 코드를 원시코드로 바꾸려면 어떻게해야하나요? [1]파일 다운로드1
5647장성욱4/7/202211938코어지정 CPU사용률 관련 질문 [1]
5646서형주4/6/202212282List에 여러개의 class 객체를 만들어 넣을때, 객체의 method들도 같이 생성되어 메모리를 차지하나요? [1]
5645김인태4/6/202211585윈도우즈 서버의 AD 계정 생성 조건이 있을까요? [1]
5644ㅇㅇ4/6/202212576c# 프로그램을 이용하여 리눅스상에 파일 생성이 가능한가요? [1]
5643유필재4/5/202212981TCP클라이언트 연결 및 통신관련하여 문의드려요 [1]
5642차가워4/4/202212909UdpClient 패킷 수신 문의 [4]
5641장성욱4/4/202212683코어 할당 및 cpu 부하테스트 질문 [7]
5640icoo...4/4/202213423웹가든에서 메모리 동적 업데이트 방법 [1]
5639차가워4/4/202214052c++ 서버 c# 클라이언트 호환 문의 [1]
5638초급4/3/202214167c# sql server 연동 [1]
5637따봉이4/1/202215592Winform Form Load 후 자동 캡쳐관련 [1]파일 다운로드1
5636김철순3/31/202214455WPF에서 Richtext의 View 문의 [5]
5635guest3/30/202213165안정적인 pinning이 가능하네요. [3]파일 다운로드1
5633꿀주세요3/30/202213109선생님 마우스 클릭이벤트 질문이 있습니다. [4]
5632김현수3/30/202213867Remote Desktop으로 접속시 WPF UI 가 다시 그려지는 이벤트를 막을 수 없을까요? [3]
5631김기헌3/24/202213254WPF 컨트롤의 그래픽 처리관련 질문드립니다 [2]파일 다운로드1
1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...