Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2004, 12:12 PM
Authorized User
 
Join Date: Aug 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default FileSystemWatcher Class

Question on the FSW class. I have it set to watch all files in a given direcotry with the filter set to *.* or null "". Is it possible to set it up to ONLY watch directories for changes, etc, and NOT watch files?

Thanks,

Billy

 
Old December 3rd, 2004, 01:54 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What changes you are talking about? Can you explain little more?

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old December 3rd, 2004, 08:37 AM
Authorized User
 
Join Date: Aug 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok,

Right now the FSW Class is watching a Directory for me call it X:\Test. If a file is deleted, renamed, or attributes changed in this direcotry I get an email on what file it was and who did it. Now I want to not get notices when the files under that directory are affected but rather when the directory itself is X:\Test. Is this possible?

 
Old December 6th, 2004, 04:37 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the property "IncludeSubdirectories" and set that to "True" to enable events on subdirectories also. On the event you can check the file affected is within the directory ("X:\Test") if it is then skip or if it is within one of the subdirectories then you can proceed processing.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old December 6th, 2004, 04:41 AM
Authorized User
 
Join Date: Aug 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the idea. However I already have subdirectories on. My problem is that I do not want to log the files being deleted renamed etc but only the directories themselfs. So as in the orginal example. If X:\Test got deleted I would like to know that and not if X:\Test\test.txt got deleted.

Thanks,

Billy

 
Old December 6th, 2004, 04:55 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check within the event it is a directory or not if it is an directory then proceed with processing.

To find whether the path is directory or not, use like blow

if(Directory.Exists(e.FullPath ))
{

}

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the FileSystemWatcher Control Eyob_the_pro C# 0 January 4th, 2007 03:08 AM
FileSystemWatcher brawny4 Visual Basic 2005 Basics 3 December 28th, 2006 12:47 PM
FileSystemWatcher? [C#] [email protected] General .NET 2 May 13th, 2005 03:50 AM
HELP - FileSystemWatcher Problems [email protected] Pro VB.NET 2002/2003 0 January 10th, 2005 09:37 PM
FileSystemWatcher Problem [email protected] VB.NET 0 December 18th, 2004 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.