filesystemwatcher

Best architecture for handling file system changes?

Here is the scenario: I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this: GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx (the internal contents aren't relevant, but it's just text da...

FileSystemWatcher Dispose call hangs

We just started running in to an odd problem with a FileSystemWatcher where the call to Dispose() appears to be hanging. This is code that has been working without any problems for a while but we just upgraded to .NET3.5 SP1 so I'm trying to find out if anyone else has seen this behavior. Here is the code that creates the FileSystemWatch...

Reading changes in a file in real-time using .NET

I have a .csv file that is frequently updated (about 20 to 30 times per minute). I want to insert the newly added lines to a database as soon as they are written to the file. The FileSystemWatcher class listens to the file system change notifications and can raise an event whenever there is a change in a specified file. The problem is t...

System.IO.FileSystemWatcher to monitor a network-server folder - Performance considerations

I want to watch a folder tree on a network server for changes. The files all have a specific extension. There are about 200 folders in the tree and about 1200 files with the extension I am watching. I can't write a service to run on the server (off-limits!) so the solution has to be local to the client. Timeliness is not particularly im...

Why does FileSystemWatcher create multiple change events when I copy a file to the directory

I've written a small test application using the .Net FileSystemWatcher to keep an eye on a directory. When I copy a large-ish (a few Mb) file into that directory I get the following events listed (see screenshot - and ignore the Delete event to begin with). I get a created event (as expected), but then two changed events (about 0.7 se...

VBA watch file in use

I"m looking for something (Win API calls or whatever) to notify me when a file becomes available for editing (i.e. no longer in use). Should I set up a timer to check the files on some interval or is there a good way to set up a watch on the file? ...

FileSystemWatcher vs Polling to watch for changes

I need to setup an application that watches for files being created in a folder (locally or on a network drive) and I was wondering if anyone has any thoughts on whether the FileSystemWatcher or polling on a timer would be the best option. I have used both methods in the past, but not extensively. Have you run into any issues (performanc...

FileSystemWatcher and network disconnect?

How can I make it work in a network? It works then it stops working without reason (maybe because the network isn't perfect). ...

How do you unit test a FileSystemWatcher event?

I am working on a system that processes documents that are dumped into a target directory. I pick up the files by detecting the FileSystemWatcher OnChanged event. As part of a unit test, how should I go about automating this? How should I organize the input files and the output files that get compared to verify that the transformation...

How do you monitor file access and changes on a file server by user name?

I was asked to find a way to monitor changes (modification, renaming, deletion, moving) of files in specific folders on the company's shared file server (simple windows shared directory). I wrote a simple app in C# that uses FileSystemWatcher to monitor these changes and notify a particular email address of them. What I'd like to know n...

how to watch FS for change

I'm doing a project in a course at my university on distributed systems. I'm planning on creating something similar to Dropbox ( getdropbox.com ), but with some sort of non-centralized peer-to-peer twist to it. For this i need some method of detecting change in a directory structure. How do you think Dropbox do this? Their implementation...

C# FileSystemWatcher does not catch a Perforce revert

C# FileSystemWatcher does not catch a Perforce revert. It works fine when the same file is modified. This causes a problem because the revert changes the file, but FileSystemWatcher does not get notified. How do you watch for a Perforce revert? Thank you. ...

Handling multiple Change Events in FileSystemWatcher

I have the following sub: Private Sub Watcher_Changed(ByVal sender As System.Object, ByVal e As FileSystemEventArgs) If Path.GetExtension(e.Name) = ".p2p" Then Exit Sub Else Try ' multiple change events can be thrown. Check that file hasn't already been moved. Whi...

File Watcher - get the process name that created a file in Windows?

Is there a good way to get the process name that created a file in Windows? I have a directory on a Windows 2000 Server C:\WINNT\Temp that is filling up with files named like: 70618199 21834082 They are always 121,201 KB in size. Programatically can I "capture" the program name or service name that is dropping files in this locati...

VB.NET FileSystemWatcher Multiple Change Events

Hi. I have the following code: Imports System.IO Public Class Blah Public Sub New() InitializeComponent() Dim watcher As New FileSystemWatcher("C:\") watcher.EnableRaisingEvents = True AddHandler watcher.Changed, AddressOf watcher_Changed End Sub Private Sub watcher_Changed(ByVal sender...

FileSystemWatcher.WaitForChanged returns, but there is still a lock on the file

I have a program that send a document to a pdf printer driver and that driver prints to a particular directory. After the print I want to attach the pdf to an e-mail (MailMessage) and send it off. Right now, I send the document to the printer (wich spawns a new process) and then call a FileSystemWatcher.WaitForChanged(WaitForChangedRes...

How does FileSystemWatcher work on another computers directory?

Something intrigues me and I don't find any resource on this. How can FileSystemWatcher know when a file on a computer "A" is created/removed/changed/renamed ? I thought that this worked with polling, (the observer polls the server to check update), but after verifying the network activity with Wireshark I saw that polling was not use...

How to have a FileSystemWatcher thread run forever?

I need to have a FileSystemWatcher run in an infinite loop to monitor a file for changes, but this file will only change every few days, and maybe only once a week. In the MSDN sample of a FileSystemWatcher, there is a loop while the user doesn't enter q at the console: while(Console.Read()!='q'); I don't want this to be constantly a...

Why doesn't FileSystemWatcher detect changes from Visual Studio?

I have made a tiny application that responds to changes to files in a folder. But when I edit the file in Visual Studio 2008, it never detects anything. If I edit the file in Notepad instead, everything works as expected. Surely Visual Studio saves the file at some point, but the watcher does not even trigger when I close the studio. Do...

File access error with FileSystemWatcher when multiple files are added to a directory

I am running into an issue with a FileSystemWatcher when multiple files are placed into the watched directory. I want to parse the file as soon as it is placed in the directory. Typically, the first file parses fine, but adding a second file to the directory causes an access issue. Occasionally, the first file doesn't even parse. The...