Questions tagged [filesystemwatcher]

FileSystemWatcher is a .NET component class that listens to the file system change notifications and raises events when a directory, or file in a directory, changes.

The System.IO.FileSystemWatcher component class can be used in .NET applications to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. These changes can be observed on a local computer, a network drive, or a remote computer.

The Filter property can be set with a string value indicating which files and/or directories are to be watched for changes.

1220 questions
388
votes
44 answers

FileSystemWatcher Changed event is raised twice

I have an application where I am looking for a text file and if there are any changes made to the file I am using the OnChanged eventhandler to handle the event. I am using the NotifyFilters.LastWriteTime but still the event is getting fired twice.…
user214707
  • 3,889
  • 2
  • 16
  • 3
167
votes
13 answers

FileSystemWatcher vs polling to watch for file changes

I need to setup an application that watches for files being created in a directory, both locally or on a network drive. Would the FileSystemWatcher or polling on a timer would be the best option. I have used both methods in the past, but not…
Jon Tackabury
  • 47,710
  • 52
  • 130
  • 168
131
votes
3 answers

Notification when a file changes?

Is there some mechanism by which I can be notified (in C#) when a file is modified on the disc?
PaulB
  • 23,264
  • 14
  • 56
  • 75
129
votes
3 answers

Using FileSystemWatcher to monitor a directory

I am using a Windows Forms Application to monitor a directory and move the files dropped in it to another directory. At the moment it will copy the file to another directory, but when another file is added it will just end with no error message.…
deepseapanda
  • 3,717
  • 8
  • 32
  • 39
105
votes
10 answers

How to monitor a complete directory tree for changes in Linux?

How can I monitor a whole directory tree for changes in Linux (ext3 file system)? Currently the directory contains about half a million files in about 3,000 subdirectories, organized in three directory levels. Those are mostly small files (< 1kb,…
Udo G
  • 12,572
  • 13
  • 56
  • 89
73
votes
6 answers

How to set filter for FileSystemWatcher for multiple file types?

Everywhere I find these two lines of code used to set filter for file system watcher in samples provided.. FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Filter = "*.txt"; //or watcher.Filter = "*.*"; But I want my watcher to monitor…
nawfal
  • 70,104
  • 56
  • 326
  • 368
58
votes
2 answers

Use FileSystemWatcher on a single file in C#

When I try to set the watcher path to a single file like so: watcher.Path = filePath1; I get the error: The directory name C:\Cromos 3.0\repository\diagnostics\dwm01_2011_06_13__09_03.LXD is invalid. Can you only set the path to a folder…
Jimmy
  • 2,191
  • 6
  • 25
  • 45
47
votes
7 answers

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…
CAD bloke
  • 8,578
  • 7
  • 65
  • 114
42
votes
9 answers

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…
Tai Squared
  • 12,273
  • 24
  • 72
  • 82
42
votes
6 answers

FileSystemWatcher not firing events

For some reason, my FileSystemWatcher is not firing any events whatsoever. I want to know any time a new file is created, deleted or renamed in my directory. _myFolderPath is being set correctly, I have checked. Here is my current code: public void…
gwin003
  • 7,432
  • 5
  • 38
  • 59
38
votes
4 answers

java.nio.file.WatchEvent gives me only relative path. How can I get the absolute path of the modified file?

I am using Java 7, java.nio.file.WatchEvent along with the WatchService. After registering, when I poll for ENTRY_MODIFY events, I cannot get to the absolute path of the file for the event. Is there any way to get to the absolute path of the file…
user1000258
  • 567
  • 2
  • 8
  • 16
37
votes
4 answers

.NET filesystemwatcher - was it a file or a directory?

Is there a way to determine with the FSW if a file or a directory has been deleted?
Arno
  • 371
  • 1
  • 3
  • 3
33
votes
7 answers

Monitor multiple folders using FileSystemWatcher

Whats the best way to monitor multiple folders (not subdirectories) using FileSystemWatcher in C#?
Bi.
  • 1,846
  • 8
  • 25
  • 34
29
votes
6 answers

watching a directory in ruby

We have an application that needs to process incoming files that are dropped into a directory. I am looking for the best way to do this. We have been using a looping Backgroundrb process, but, to be honest Backgroundrb is unreliable and we'd like…
phil
  • 4,668
  • 4
  • 33
  • 51
28
votes
1 answer

What are practical limits on the number of FileSystemWatcher instances a server can handle?

I have a windows service that is currently instantiating about a dozen FileSystemWatcher instances to monitor shared folders across the corporate network for files to be processed. I am looking into adding more instances so I'm wondering if anyone…
Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
1
2 3
81 82