Solved

FileSystemWatcher & OnDeleted action - file or folder was deleted?

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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