filesystemwatcher

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

余生长醉 提交于 2019-11-28 18:41:48
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 here has experience (with production systems) as to what are practical limits on number of FileSystemWatcher instances a production system can reliably handle? Edit: In my case, the InternalBufferSize property is not modified so the InternalBufferSize is the default 8 KB... I assume the increase in InternalBufferSize would affect the number of

Watching for file and directory changes in Java

北慕城南 提交于 2019-11-28 12:52:05
I'm writing here mostly for advice on where to start. I've already implemented a class that will recursively watch a directory using Java's WatchService. It works quite alright for detecting changes, but I've noticed a fatal flaw: I cannot delete directories that are being watched that contain directories that are being watched. This seems to be a limitation of WatchService. I have also looked into Apache's VFS FileListener a bit, but before I spend another 6-or-so hours of my time building some kind of wrapper around it, I figured maybe I'd just ask those more knowledgeable than myself. I

How do I know when a file has been modified in a VBA Macro?

爷,独闯天下 提交于 2019-11-28 12:46:15
Is there a way to watch a file in VBA (which is essentially VB6), so that I know when the file has been modified? -- similar to this only I don't want to know when a file is unused , just when its modified . The answers I've found have recommended using "FileSystemWatcher" and the Win32 API "FindFirstChangeNotification". I can't figure out how to use these though, any idea? Okay, I put together a solution that is able to detect file system changes, in VBA (VB6). Public objWMIService, colMonitoredEvents, objEventObject 'call this every 1 second to check for changes' Sub WatchCheck() On Error

FileSystemWatcher to execute .NET functions

余生长醉 提交于 2019-11-28 10:49:33
问题 I am creating a quick temporary fix so sorry if this is dirty, but- Objective I would like to use Powershells Register-Event cmd to wait for a file dropped in a folder, then call a function that parses the file and outputs it to excel. I don't need help with the coding aspect, just the concept. It is still a little mysterious to me as of where this Event is running and what resources it has to work with. Things I've Tried One .ps1 file with registered events at the bottom, calling a function

FileSystemWatcher pitfalls

ぃ、小莉子 提交于 2019-11-28 10:29:10
I am working on a C# program that needs to use the FileSystemWatcher class so it will be notified when new files are created. As part of the initialization, the program scans the directory so it can process any files that already exist in it. This is all working fine. However, in a discussion with another developer, we started questioning whether this will always work. Are there conditions under which the FileSystemWatcher will miss the creation of files? If so, what are these conditions? In order to handle this scenario, we would just run the code in our initialization process that scans the

VB.NET FileSystemWatcher Multiple Change Events

社会主义新天地 提交于 2019-11-28 09:14:14
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 As Object, ByVal e As FileSystemEventArgs) MsgBox(e.FullPath) End Sub End Class When I run it and save changes to a file on my C drive, the code works great, except it executes the watcher_Changed() method four times. Any idea why? The changeType is "4" every time. Thanks. John Kurlak From the "Troubleshooting

FileSystemWatcher stops catching events

怎甘沉沦 提交于 2019-11-28 09:08:15
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 losing connection to the server or there is a glitch in the network. How can I handle this situation in the code. Is there some exception I can watch for and try to restart the FileSystemWatcher object. Any suggestions and code samples would be appreciated. Rene The previous answer does not fix it completely, I had to reset the watcher not just turn it on

Does anyone have a FileSystemWatcher-like class in C++/WinAPI?

久未见 提交于 2019-11-28 07:42:32
I need a .Net's FileSystemWatcher analog in raw C++/WinAPI. I almost started to code one myself using FindFirstChangeNotification/FindNextChangeNotification, but then it occurred to me that I am probably not the first one who needs this and maybe someone will be willing to share. Ideally what I need is a class which can be used as follows: FileWatcher fw; fw.startWatching("C:\MYDIR", "filename.dat", FileWatcher::SIZE | FileWatcher::LAST_WRITE, &myChangeHandler); ... fw.stopWatching(); Or if it would use somehting like boost::signal it would be even better. But please, no dependencies other

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

天大地大妈咪最大 提交于 2019-11-28 07:13:34
Is there a way to determine with the FSW if a file or a directory has been deleted? Here's a simplified and corrected version of fletcher's solution: namespace Watcher { class Program { private const string Directory = @"C:\Temp"; private static FileSystemWatcher _fileWatcher; private static FileSystemWatcher _dirWatcher; static void Main(string[] args) { _fileWatcher = new FileSystemWatcher(Directory); _fileWatcher.IncludeSubdirectories = true; _fileWatcher.NotifyFilter = NotifyFilters.FileName; _fileWatcher.EnableRaisingEvents = true; _fileWatcher.Deleted += WatcherActivity; _dirWatcher =

How to set filter for FileSystemWatcher for multiple file types?

半世苍凉 提交于 2019-11-28 06:08:26
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 more file types, but not all. How can I achieve this: //watcher.Filter = "*.txt" | "*.doc" | "*.docx" | "*.xls" | "*.xlsx"; I tried these: watcher.Filter = "*.txt|*.doc|*.docx|*.xls|*.xlsx"; // and watcher.Filter = "*.txt;*.doc;*.docx;*.xls;*.xlsx*"; Both did not work. This is just basics but I miss it. Thanks.. There is a workaround. The idea is to