FileSystemWatcher - How to find out file / directory

  • Thread starter Thread starter fitsch
  • Start date Start date
F

fitsch

Hi,

Here comes another newbie question:

I am using the FileSystemWatcher. The filter I have set to "*.*". On
the events, I can access the FileSystemEventArgs.

How do I find out, if it is a file or a directory?

Thanks for any advice...

Greets,

Phil
 
Try this in your event handler:

void MyHandler(object sender, FileSystemEventArgs e)
{
FileInfo fi = new FileInfo(e.FullPath);
bool isDir = fi.Exists &&
(fi.Attributes & FileAttributes.Directory) ==
FileAttributes.Directory);
}

Regards,
Joakim
 
Back
Top