Solved

FileSystemWatcher & OnDeleted action - file or folder was deleted?

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

821 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