?
Solved

FileSystemWatcher & OnDeleted action - file or folder was deleted?

Posted on 2004-10-07
2
Medium Priority
?
807 Views
Last Modified: 2008-02-26
Hi All.

In my .NET app I use 'FileSystemWatcher class' and his handlers - Changed, Created, Renamed and Deleted which return 'e.FullPath' value.

How to determine if 'e.FullPath' is 'file' or 'folder' in OnDeleted action?

I use simple test 'Directory.Exists(e.FullPath)' in OnChanged, OnCreated and OnRenamed actions. But in OnDeleted action I cannot pass this test because e.FullPath object was just deleted.

Any idea?

Thanks Martin
0
Comment
Question by:martin_mmj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
prasitlee earned 250 total points
ID: 12246946
Hi Martin,
    I think you can see the result of the following attributes of the class "NotifyFilter" to check if the deleted file was folder or file. Let 's check these attributes "DirectoryName" and "FileName". I think there would show the different value once you delete folder and file.
    Unfortunately, I didn't have Visual Studio .Net on my machine now. I would test and let you later once I returned to my home and test the code from the following link http://www.codeproject.com/dotnet/folderwatcher.asp
    However, if you have available time to test and found that it is the solution for your question. Please feel free to let me know.
                                                       Meng
   
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question