Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

FileSystemWatcher failure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MPS35 - 14 Jul 2005 20:54 GMT
I am using the FileSystemWatcher in our product to watch for file creations,
changes, and deletions and updating the UI of our product based on those
notifications.  I have a customer that is not seeing his UI update and I
have traced it to not getting the notifications from the FileSystemWatcher.
I even had him run a test using sample code pulled from MSDN to verify that
we should be getting notifications, and that nothing with our product was
inhibiting this.  He has tried this on two computers.  On the first computer
(XP Pro SP1), we will call this computer A, he is having problem described
above, if the files are located on a network server (SBS 2000).  On computer
A, the customer seems to have no problems if the files are local.  I had him
install and test on another computer.  We will call this second computer,
computer B.  On computer B (XP Pro SP2), using the same network server,
share, and files that wouldn't work with computer A all seems to work
without incident.  In-house, we were able to somewhat reproduce this, but
only with Windows 2000 installed on Virtual PC.  In that Virtual PC we got
some notifications but very few.  If we ran the same tests on the same
computer (XP Pro SP2) that the Virtual PC was being run on, but not using
Virtual PC, we received all the notifications that we should have.  Does
anyone have any idea what might be causing this?

MPS35
"Peter Huang" [MSFT] - 15 Jul 2005 10:11 GMT
Hi,

Currently I am researching the issue and we will reply here with more
information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

"Peter Huang" [MSFT] - 16 Jul 2005 04:20 GMT
Hi

Based on my test with Window XP+SP1 to access to a folder on Windows 2000
Server + SP4, it can not get the notification.
Here is my test code.
using System;
using System.IO;
using System.Diagnostics;
namespace FWT
{
    public class Watcher
    {

        public static void Main()
        {

            string[] args = System.Environment.GetCommandLineArgs();

            // If a directory is not specified, exit program.
            if(args.Length != 2)
            {
                // Display the proper way to call the program.
                Console.WriteLine("Usage: Watcher.exe (directory)");
                return;
            }

            // Create a new FileSystemWatcher and set its properties.
            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = args[1];
            /* Watch for changes in LastAccess and LastWrite times, and
              the renaming of files or directories. */
            watcher.NotifyFilter = NotifyFilters.LastAccess |
NotifyFilters.LastWrite
                | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            // Only watch text files.
            watcher.Filter = "*.txt";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(OnChanged);
            watcher.Created += new FileSystemEventHandler(OnChanged);
            watcher.Deleted += new FileSystemEventHandler(OnChanged);
            watcher.Renamed += new RenamedEventHandler(OnRenamed);

            // Begin watching.
            watcher.EnableRaisingEvents = true;

            // Wait for the user to quit the program.
            Console.WriteLine("Press \'q\' to quit the sample.");
            while(Console.Read()!='q');
        }

        // Define the event handlers.
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            // Specify what is done when a file is changed, created, or deleted.
            Console.WriteLine("File: " +  e.FullPath + " " + e.ChangeType);
        }

        private static void OnRenamed(object source, RenamedEventArgs e)
        {
            // Specify what is done when a file is renamed.
            Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
        }
    }
}

Also I suggest you try to apply the recently Service Pack before test.
From the Document below, Windows 2000 may lost packet when it has not
install SP2 or high and the VM may have poor performance in contrast with
physically machine.

Windows NT 4.0:  The limit in this situation is 4 KB.

Windows 2000:  Clients that attempt multiple simultaneous long-term
requests against a server, for example change notifications, should be
running Service Pack 2 or higher. See Knowledge Base article Q271148 for
more details.
Windows Me:  There is similar functionality available with the
FindFirstChangeNotification function.

ReadDirectoryChangesW
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/r
eaddirectorychangesw.asp

The FileSystemWatcher will use the API above.

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

MPS35 - 22 Jul 2005 16:39 GMT
Peter,

I'm not sure I understand your reply.  Are you saying that you could not get
this to fail?  You mention the KB article Q271148.  This describes how it
could fail in 2000.  Do these same parameters described in that article
exist in XP?

Thanks,
Mike

> Hi
>
[quoted text clipped - 90 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
"Peter Huang" [MSFT] - 23 Jul 2005 05:38 GMT
Hi

Per the KB the problem existed in Windows 2000 before service pack 2, I did
not find a similar problem with XP.
Also based on my test, the problem  will not persist on a windows XP +SP1.

So I suggest you may try my code on the problem XP+SP1 to see if that is
any difference.

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.