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

... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...
NoWriterDateCnt.TitleFile(s)
736김현기1/24/200817346XML 접두어 포함한 XmlElement 작성법? [1]
735정명원1/9/200817196ActiveX 사용시 ... [2]
734제영한12/17/200717222웹서비스에서 사용자 정의 예외 사용하기 [2]
732김기룡12/3/200720340WebRequest 요청시 일본어 인코딩 관련 문의 [3]파일 다운로드1
731우기11/27/200714897[질문] clickonce 배포시 .net framework 2.0, 3.0 설치 시간 줄일 수 있는 묘수없을까요?? [1]
730김재영11/10/200716100스레드에 사용되는 함수에 값을 같이 넘기는 방법이 있습니까?? [2]파일 다운로드1
727제영한10/24/200714881시스템 설계에 대한 문의드립니다. [2]
726한귀순10/24/200716265SQL 2005 Express 사용시.. [3]
725이방은10/23/200716742성태님 GDI+질문있어요.. [2]
724clic...10/17/200717725clickonce 작동시 무반응입니다. [1]
722한귀순10/11/200721323Internet Explorer 7.0 에서 ClickOnce Error [3]
721이카루스10/5/200717696WCF 질문드립니다. [1]
720limj...10/5/200717252인증서/스마트 카드에 기반한 Managed Card - STS 구현 질문 [2]
718DJ.처리10/2/200726451[VS.NET 2008] 스마트클라이언트 게시 오류...도와주세요~ [2]파일 다운로드2
716guest9/28/200720966실행시간이 긴 com+ 객체가 죽는거 같습니다. 어떻게 해야 할지.... [3]
713하민규9/19/200715646VC++ 6과 Vista UAC .. [1]파일 다운로드1
711술푼어둠이9/17/200716217사설 IP 사용 문제?? [1]파일 다운로드1
709한귀순9/14/200715728asp.net 에서의 paging 관련. [2]
708이준영9/13/200717866마우스 커서의 움직이는 속도 알아내는 좋은 방법은? [1]
707hatu...9/10/200716027window2000과 ssl 그리고 frame [2]
701소쿠리9/5/200716657Get 으로 넘긴 한글 문자열 Respose.AddHeader 에서 filename 으로 사용시 깨짐. [1]
699유현기9/3/200716394[질문1]스마트 클라이언트에서 웹의 변수를 스마트 클라이언트에서 받아쓰기(제발도와주세요 ㅠ.ㅠ) [1]파일 다운로드1
696clev...8/31/200715940Exe COM으로 만들면 혹시 Bridge dll없이도 권한 상승이 가능한가요? [2]
695스마일8/30/200715806Visaul Studio 2005에서 디버깅이 안되요...ㅠㅠ [1]
694이호정8/29/200716099[CardSpace 관련 질문] 정리해 좋으신 글 잘 보았습니다. [4]
693장근배8/29/200715770매핑 구간이 열려 있습니다 [3]
... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...