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
26
votes
3 answers

How to watch a directory for changes?

Could not find anything in python core to do this. Can anyone recommend a library or "battery" to do this? Ideally I would like this to be portable but it's OK if it is available only for Unix (my server).
Gnu Engineer
  • 1,495
  • 2
  • 13
  • 15
26
votes
5 answers

FileSystemWatcher to watch UNC path

There are no shortage of questions on this topic, but I'm still having trouble. Here is my situation. I've got a service that I need to watch a path that is specified in the config file. It works great when I used a local drive. However, when I…
nickfinity
  • 1,119
  • 2
  • 15
  • 29
25
votes
1 answer

How reliable is the FileSystemWatcher in .netFramwork 4?

Has anyone used the FileSystemWatcher in framework 4 and have you encountered any problems? i am using it in a windows service and i cant afford for it to fail. I have heard from a friend that it is not very reliable but I have been testing for a…
Yugz
  • 677
  • 1
  • 10
  • 23
25
votes
2 answers

Which filter of FileSystemWatcher do I need to use for finding new files

So far I know that FileSystemWatcher can look into a folder and if any of the files inside that folder is changed,modifies,.etc... then we can handle it. But I am not sure which filter and event I should use in my scenario: Watch for a Folder, If a…
Bohn
  • 26,091
  • 61
  • 167
  • 254
24
votes
3 answers

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…
Haugholt
  • 837
  • 9
  • 15
24
votes
3 answers

FileSystemWatcher stops catching events

I am writing a c# program to let me know when a file has been added or deleted. I run it on my Windows 7 machine and watch an FTP server on our network. It works fine but will suddenly stop catching any events. I'm guessing that it might be…
Paul
  • 757
  • 3
  • 10
  • 38
23
votes
1 answer

Why FileSystemWatcher doesn't work in Linux container watching Windows volume

Given the program: using System; using System.IO; namespace fsw_bug_poc { class Program { private static FileSystemWatcher _fileSystemWatcher; static void Main(string[] args) { _fileSystemWatcher = new…
natenho
  • 5,231
  • 4
  • 27
  • 52
23
votes
6 answers

Detecting moved files using FileSystemWatcher

I realise that FileSystemWatcher does not provide a Move event, instead it will generate a separate Delete and Create events for the same file. (The FilesystemWatcher is watching both the source and destination folders). However how do we…
Ash
  • 60,973
  • 31
  • 151
  • 169
19
votes
1 answer

Does FileSystemWatcher create its own thread?

I want this work to be done in a different thread but do i have to create a thread or does it do all the work on different threads? Like: Thread fileThread = new Thread(() => { FileWatcher = new FileSystemWatcher(); FileWatcher.Created +=…
syncis
  • 1,395
  • 4
  • 25
  • 43
18
votes
2 answers

Node.JS: How does "fs.watchFile" work?

According to the API docs for Node 0.4.3, the fs.watchFile(filename, [options], listener) function starts a routine that will Watch for changes on filename. The callback listener will be called each time the file is accessed. It also says The…
700 Software
  • 85,281
  • 83
  • 234
  • 341
18
votes
2 answers

How to run an function when anything changes in a dir with Python Watchdog?

I'm trying to use watchdog to run a sync script whenever anything changes in a dir (except for one specific file). I simply copied the code from the readme (pasted below), which does what it says; log which file has changed. import sys import…
kramer65
  • 50,427
  • 120
  • 308
  • 488
17
votes
5 answers

How do I get this event-based console app to not terminate immediately?

Source class Program { static void Main(string[] args) { var fw = new FileSystemWatcher(@"M:\Videos\Unsorted"); fw.Created+= fw_Created; } static void fw_Created(object sender, FileSystemEventArgs e) { …
mpen
  • 272,448
  • 266
  • 850
  • 1,236
17
votes
6 answers

FileSystemWatcher does not report changes in a locked file

I'm monitoring a folder using a FileSystemWatcher like this: watcher = new FileSystemWatcher(folder); watcher.NotifyFilter = NotifyFilters.Size; watcher.Changed += changedCallback; When I open a new file in notepad in that folder and save it, I get…
Eldad Mor
  • 5,405
  • 3
  • 34
  • 46
16
votes
6 answers

Avoid Error too many changes at once in directory

how to avoid the error of FileSystemWatcher in C#? too many changes at once in directory I have to detect all changes on a network share. The InternalBufferSize is increased to 8192 * 128
DerAbt
  • 337
  • 1
  • 5
  • 14
15
votes
5 answers

Filesystem watcher and large files

var fsw = new FileSystemWatcher(sPath, "*.PPF"); fsw.NotifyFilter = NotifyFilters.FileName; fsw.IncludeSubdirectories = true; fsw.Created += FswCreated; fsw.EnableRaisingEvents = true; static void FswCreated(object sender, FileSystemEventArgs e) { …
NickD
  • 2,672
  • 7
  • 37
  • 58
1
2
3
81 82