Solved

FileSystemWatcher & OnDeleted action - file or folder was deleted?

Posted on 2004-10-07
2
786 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

18 Experts available now in Live!

Get 1:1 Help Now