 |
|
|
 |
|
 |
Your file watch utility looks like a great tool; however, I have run into some problems trying to get the application working. When I attempt to start the app, either from within Visual Studio 2008 or directly from the exe, I receive the following error,
"Error while trying to run project: Unable to start program 'C:\Workspace\AdvancedFSWatcher\bin\Debug\AdvancedFSWatcher.exe'. The application has failed to start because the application configuration is incorrect. Review the manifest file for possible errors. Reinstalling the application may fix this problem. For more details, see the application event log."
When I investigate the event log, here is what I find,
"Source: SideBySide Type: Error Event ID: 59 Description: Generate Activation Context failed for C:\Workspace\AdvancedFSWatcher\bin\Debug\AdvancedFSWatcher.exe. Reference error message: The operation completed succesfully."
Do you have any suggestions?
TIA.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I used the FileSystemWatcher class and discovered a few problems:
* If you are dealing with a local disk with write cache enabled, changed events do not seem to be raised properly when writing files to disk. * As stated in the MSDN documentaton, the internal buffer may need to be extended to deal with event overload. Make sure you set it to an appropriate value, the FileSystemWatcher class does not provide much in the way of notification of incorrect parameters. Implement the Error event handler and look at the Exception thrown if you see unexpected results. * If too many events are raised at once, the class throws an exception - again, remember to implement the error event handler. * As stated in this artcile the class is not capable of reinitiating watching if network connectivity is lost. * Watching network drives worked fine for me as long as I use UNC paths (mapped drive letters appear to generate no events at all). * If you run too frequent calls you could see the error "the network bios command limit has been reached": http://support.microsoft.com/kb/810886
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Some more detail:
* It seems it is not just cache features of hard drives that may cause trouble. RAID controllers and the like seem to swallow all change events except the first one when the file copy / move starts. * Code Access Security can be a problem, u may need to add the URL with full trust. My Computer => Runtime Security Policy => Machine => Code Groups => All_Code. Expand, and right click to create a new group. Use a URL condition type, type in your URL. Something like: file://\\srvname\sharename\* . Set full trust. If this works you should try to eliminate the full trust in favor of the minimum rights that work.
In summary: don't trust this class. It looks great, and is great when it works. It just never works.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello, I am using filesystem watcher for H drive which is USB Drive. it's working fine.
when i am paste a file into H Drive. i want path of copying file where from file is copied.
Thanks
Anubhava Dimri
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
Thanks for your code first. I have a recommendation.
Private Sub _myTimer_Elapsed should check the EnableRaisingEvents to make the code more consistent. If EnableRaisingEvents = False then Return ' without further processing End IF
This is because when I use the Advanced FileSystemWatcher, I new() an instance but have not specified the Path yet. There is still exception "The path is not of a legal form." raised.
|
| Sign In·View Thread·PermaLink | 2.33/5 (2 votes) |
|
|
|
 |
|
 |
Hi, I really appreciate the code you have developed... I am using your code for my project.
I need help to determine the source file.
i.e. if a file is copied from source to destination and the destination folder is being monitored then a "file created" Event will be triggered and we get the file created with the proper path.. Now i want that the file copied from (Source path)also.
Hope you got me.
Any help are thankful.
Dinesh Gadewal Patni Computer Systems
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Dinesh,
The only way you can get the Source path is to watch that folder as well.
If you are Copying the file, then you would not see an event on the source path during the Copy. However if you do a MOVE you should see a file deleted event on the source path, and a file created on the destination path.
The only other thing you could do, in the event of a Copy, is modify the source file, just prior to copying it, say change the date created or something, then you should see a file changed event in the source path, But again you must also be watching that path as well.
HTH

Get access to awsome .Net Videos at www.learnVisualStudio.net
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
 |
Hi,
The idea is bit tricky, will work but i am afraid cause when it comes to generalizing it would cause problem.
A new drive can be plugged any time keeping watch on them would cause problem at runtime...
Isnt there a "COPY EVENT" which windows uses and VB .NET can track that event???
If that is possible, it would solve a lot problems for me...
Any help is thankful.
Regards, Dinesh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I've used FSW before, and like you ended up writing a wrapper to add 'missing' functionality.
Spedifically, the FSW.FileCreated event fires when a file has STARTED being created. This is no use if you try to do something with a file as soon as you get the notification, i.e. like read the contents, or even worse, move it.
I changed the FileCreated Event to STARTFileCreated, and added a ENDFileCreated event of my own.
Another major limitation is that the FSW can only monitor ALL files (*.*) or ONE type of file (e.g *.txt).
FSW is good, but it took me ages to make it do what I actually want. There are some discussions on this on MSDN Technical forums (i'm Anarchy), look here http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=659823&SiteID=1[^] if you're interested
Ade
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Jon_dylon,
I understand what you are talking about, we have a work around, and basicaly we create a "DONE" file that we look for and that is put in the folder after the file we want is in the folder.
I would be interested in looking at what you did to add the EndFileCreated event.
Thanks
Get access to awsome .Net Videos at www.learnVisualStudio.net
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Jon,
I went to the link and saw what you were doing. I love the way you spun it up on a background thread. Nicely done!
I have modified my Advanced File System watcher to include your events. I was wondering if I could get your permission to include it with mine, and post the new version up here?
I would of course give you props for your code in the source code.

Thanks again George
Get access to awsome .Net Videos at www.learnVisualStudio.net
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
 |
Another solution that I came up with is:
1) When the file creation event gets fired.. 2) Open another filesystem watcher only on that file and wait for NotifyFilters.LastWrite 3) When LastWrite gets fired, he is done copying that file -> and you close the watcher for that file:
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Yes! Here is an example:
// main filesystem watcher FileSystemWatcher fsWatcher = new FileSystemWatcher(); fsWatcher.Created +=new FileSystemEventHandler(fsWatcher_Created);
// to keep track of the subwatchers.. Hashtable htWatchers = new Hashtable();
private void fsWatcher_Created(object sender, FileSystemEventArgs e) { FileSystemWatcher subWatcher = new FileSystemWatcher(); subWatcher.Changed +=new FileSystemEventHandler(subWatcher_Created); subWatcher.Path = e.FullPath.Substring(0,e.FullPath.LastIndexOf('\\')); subWatcher.Filter = e.Name.Substring(e.Name.LastIndexOf('\\')+1); subWatcher.NotifyFilter = NotifyFilters.LastWrite; subWatcher.EnableRaisingEvents = true; if (htWatchers.ContainsKey(e.FullPath)) { htWatchers.Remove(e.FullPath); } htWatchers.Add(e.FullPath,subWatcher); }
// now the new file copy should be done.. private void subWatcher_Created(object sender, FileSystemEventArgs e) { this.textBox_eventWindow.AppendText(e.Name + ": " + e.ChangeType.ToString() + "\r\n");
if (htWatchers.ContainsKey(e.FullPath)) { htWatchers.Remove(e.FullPath); } }
|
| Sign In·View Thread·PermaLink | 4.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
Have either of you two posted this feature? I knew of this double firing problem when I first looked into this solution for the Filewatcher. I like the manner your are implementing the fix and I am sure we ALL would appreciate that code updated to the article solution.
Cheers! ~Mann.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
For what it's worth, I had trouble with the FSW for the same reason you mention. As soon as the file started coping to the directory, it would fire my code. I solved it by putting the file path & name in a queue and using a SyncLock to make sure the queue wasn't crashing into itself when putting files in and taking them out of the queue. I'd perform looping where necessary. It seems like Stoti's way would be better, but if you're having trouble, you might look at the SyncLock.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The example didnt work for me. Whenever i moved 70 MB file to the watched folder the subwatcher_created was called 3 times. What might be the problem?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Interesting. I will try that out myself. Do I have to consider anything special or just moving a big file in a subfolder?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |