Solved

FileSystemWatcher & OnDeleted action - file or folder was deleted?

Posted on 2004-10-07
2
788 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
2 Comments
 
LVL 6

Accepted Solution

by:
prasitlee earned 125 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now