filesystemwatcher

How to check in Node.js if a file is open/being written to?

纵饮孤独 提交于 2019-12-04 10:18:21
I found many answers for C++, C#, etc. but haven't yet found one for Node.js. Here is my case. I've created a module which watches for file/directory changes (new or updated, doesn't care about deleted files) in my FTP server. Once I notice a new file, or an existing one is changed, I get a notification and notify my module B to sync this file to Sourceforge.net. The module works fine, reacts to changes instantly. But what I'm not satisfied with yet is that when a new file is added, that file receives "modified" event several times depending on the file size: the bigger the size, the more

FileSystemWatcher under mono - watching subdirs

不想你离开。 提交于 2019-12-04 07:37:48
I have a problem. I have written a wrapper over FileSystemWatcher that detects changes in root folder and all of its subfolders. Nothing fancy: FileSystemWatcher watcher = new FileSystemWatcher (); watcher.Path = this.Root; watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.DirectoryName | NotifyFilters.FileName; watcher.Changed += new FileSystemEventHandler (watcher_Changed); watcher.Deleted += new FileSystemEventHandler (watcher_Deleted); watcher.Created += new FileSystemEventHandler (watcher_Created); watcher

How do you get the name of a new file created using FileSystemWatcher?

空扰寡人 提交于 2019-12-04 06:41:46
I'm monitoring a folder using FileSystemWatcher. If I download a file into there, how do I get the name of that downloaded file? For example, if I downloaded a file named TextFile.txt, how would I have it return that as a string? I am assuming this will work for all four triggers (changed, created, deleted, renamed)? I have IncludeSubdirectories set to true, so it should be able to do that. On the OnCreated event, add this code: private void watcher_OnCreated(object source, FileSystemEventArgs e) { FileInfo file = new FileInfo(e.FullPath); Console.WriteLine(file.Name); // this is what you're

Use FSEvents in sandboxed app

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:58:24
I'm trying to use FSEvents in my sandboxed app to monitor some directories. I implemented the following class: @implementation SNTracker - (id)initWithPaths:(NSArray *)paths { self=[super init]; if (self) { trackedPaths=paths; CFTimeInterval latency=1.0; FSEventStreamContext context={0,(__bridge void *)self,NULL,NULL,NULL}; FSEventStreamRef eeventStream=FSEventStreamCreate(kCFAllocatorDefault,&callback,&context,(__bridge CFArrayRef)trackedPaths,kFSEventStreamEventIdSinceNow,latency,kFSEventStreamCreateFlagUseCFTypes|kFSEventStreamCreateFlagWatchRoot|kFSEventStreamCreateFlagFileEvents);

Equivalent of FileSystemWatcher (.NET) in Cocoa

非 Y 不嫁゛ 提交于 2019-12-04 05:28:21
I am developing an application in Cocoa. I want to constantly check whether the contents of a file in a particular location is changed or not (like FileSystemWatcher in .NET). Please anyone give me a solution Please have a look at FSEvents . As Diederik says, FSEvents is Apple's Carbon API for listening to file system events. Someone has created a Cocoa/Objective-C wrapper for FSEvents called SCEvents that is a little easier to use. Another option would be to drink directly from the /dev/fsevents firehose. I work on an application that does exactly this and it works very well. You can be

FileSystemwatcher for a list of files

醉酒当歌 提交于 2019-12-04 04:48:56
问题 I have been following the guidance here FileSystemWatcher Changed event is raised twice. However I have a list of files that I'm watching so if I delete 20 files together the event is called 20 times. This is expected and works fine. How can I only have an event fired once for 20 "simultaneous" file changes (i.e How can I ignore all other file changes until the code in the first instance of Onchanged below has completed. Right now Onchanged is called 20 times.) ? private void Main_Load(object

After FileSystemWatcher fires - Thread Pool or Dedicated thread?

♀尐吖头ヾ 提交于 2019-12-04 03:31:18
问题 I am about to implement the archetypal FileSystemWatcher solution. I have a directory to monitor for file creations, and the task of sucking up created files and inserting the into a DB. Roughly this will involve reading and processing 6 or 7, 80 char text files that appear at a rate of 150mS in bursts that occur every couple of seconds, and rarely a 2MB binary file will also have to be processed. This will most likely be a 24/7 process. From what I have read about the FileSystemWatcher

FileStream and a FileSystemWatcher in C#, Weird Issue “process cannot access the file”

独自空忆成欢 提交于 2019-12-04 01:58:36
问题 I have this complicated code-base that is listening for FileCreated events on a certain folder. When the file is Created (which also includes moving a file to that folder), I want to read in that file and do something with it. It works for the first file, but throws an exception after for all other attempts. In Debug-mode (With VisualStudio) the error would be thrown, but if i just click "continue".. it would then work (without an error). I have posted simplified code, which demonstrates the

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

99封情书 提交于 2019-12-03 23:19:11
问题 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 file is added to that folder, do XYZ ... So In my scenario I don't care if an existing file is changed,etc..those should be ignored...only do XYZ if and only if a new file has been added to that Folder... Which event and filter do you recommended

Determine when an FTP uploaded file is ready for processing using FileSystemWatcher

亡梦爱人 提交于 2019-12-03 20:32:46
I want users to be able to upload files via FTP to my site (IIS 7.5). Once the file is uploaded, then I want to process the file using FileSystemWatcher. How can you determine when the file has completed uploading to the server? I don't want to process it before it completes the entire upload. There is really no inherent way that you can know the file has completed uploading. It is even possible that it is uploaded partially first and completed later. You either need to determine from the file contents that it is a complete file or use some other marker. For example an empty file signifying