|
 |
|
|
The best approach to processing large files that are being FTP'd is to setup a process that once the large file is sent a small file (semaphore file) is sent to indicate to the receiver that the large send has completed.
Hey man the universe is just a cosmic bubble!
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
is there any way to resolve the LowerCase for e.FullPath or e.Name or e.OldFullPath. I have got a big problem for the lower case as data house stores FileName in exact formate and I have no way to make case incensetive so I am not getting result. can any on help me please.
thanks Mamun
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Can you please tell in little more detail how to test this program? Thank you.
Bharat.
In life, failures teach you as much as — or perhaps more than — successes. Thank you very much for the help.
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
The MonitorPath in the App Config file uses the current directory your application is running in as a base directory. i.e. if you're executing c:\TestFileWatcher\bin\Debug the name specified in the MonitorPath is "Monitor" this would monitor the directory c:\TestFileWatcher\bin\Debug\Monitor. So to test the app you would copy files into the Monitor directory.
Hey man the universe is just a cosmic bubble!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Can you please throw light as to how this proram works or how to test it? It is not clear what one should do when program stops at console.read() line. I have created a file watcher application, where I want to move the created file to another folder after it is obtained from ftp site.
Thank you.
In life, failures teach you as much as — or perhaps more than — successes. Thank you very much for the help.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
FileSystemWatcher fsw = new FileSystemWatcher(pickupDir, "*.XML"); fsw.NotifyFilter=NotifyFilters.Attributes; fsw.Changed += new FileSystemEventHandler(QueueFileHandler);
The attribute is changed as the last action of copy/move or ftp transfer. During the transfer, attributes are not changed.
Your directory must for recieving new files only. Move your file to a pending directory for processing in the "QueueFile" routine.
Note, this does not work on Windows 2000, only XP and Windows 2003 Servers.
Karl Rohde Solutions Architect Red Toad Solutions Ltd
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
hi,
You can set watcher.NotifyFilter = NotifyFilters.LastAccess;
Notify Filter to only last access so that when file copy is completed it will raise Changed event of FileWatcher watcher.Changed +=new FileSystemEventHandler(watcher_Changed);
which can used to process file fruther.
Have a great programming
Regards Chitrsen
Chitrsen Aujikar
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Chitrsen wrote: You can set watcher.NotifyFilter = NotifyFilters.LastAccess;
Notify Filter to only last access so that when file copy is completed it will raise Changed event of FileWatcher watcher.Changed +=new FileSystemEventHandler(watcher_Changed);
With this set will it work with very large files say 1 gig or so? And if so how would I use that in my code? Do you have a sample that you could share with me?
Thanks in advance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
With this approach, we won't be able to filter on filename. Also, correct me if I'm wrong, the last access information of a file will get updated after copying of each packet of a big file not the full file. But you have opened an idea to check the lastaccess / lastwrite timing and according process the file or not.
Thanks, Krish
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello my name is Vittorio,
I wrote a windows service that implements File System watcher and had the problem when copying a file larger than 10M and less than 50..so at that point I found your great article...so now my question is how would you implement your code using a windows service?? Please let me know since I tried to do so without obtaining any result
Thank tou very much Richard..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
This lightweight approach works great: http://www.issociate.de/board/post/234329/FileSystemWatcher_question.html
Private Sub CallingProcess System.Threading.Thread.Sleep(100)
''try to open the file in exclusive mode Do Until TryToOpenInExclusiveMode(e.Name) = True System.Threading.Thread.Sleep(1000) Loop
End Sub
Private Function TryToOpenInExclusiveMode(ByVal xmlFileName As String) As Boolean Dim fs As FileStream Try fs = New FileStream((archiveFileDirectory & "\" & xmlFileName), FileMode.OpenOrCreate, FileAccess.Read, FileShare.None) fs.Close() fs = Nothing Return True Catch ioEx As IOException fs.Close() fs = Nothing Return False Catch fnfEx As FileNotFoundException fs.Close() fs = Nothing Return False Catch uaEx As UnauthorizedAccessException fs.Close() fs = Nothing Return False End Try End Function
Pras Biswas
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Lighter in code but not weight.
Writing code in anticipation of an exception requires more processing from the host machine than "cleaner" code that only in the exceptional case throws an exception. Can you image if there are say a hundred files all throwing this exception in your system what the load would be.
I've seen this kind of coding before and its more a hack than a way to find the correct solution.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Thanks publishing your code - I must be missing something because all works fine for small files say under 100k, but for bigger files an error msg pops-up saying "process can't access file - its being used by another process". I assume what is happening is that an "OnChanged" event is not being raised as the file is being copied into the monitored directory and therefore times-out before the copy is complete. But you say you use this code for large files ... do u have nay suggestions ? Thanks Simeon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
I got the same behaviour. I have made somne test and the time interval between 2 change events raised by the FileSystemWatcher is the issue. For large files, the watcher is raising a first event, the application start the timer, the timer ends before the next change event is raised. So when you try to move the file you got the exception about concurent access.
I have no solution yet except catching the exception and doing it again after a while. I don't know how windows is managing the progress bar while file is copied, something must exist which can give us the information that the file is still copying...
Hope it helps,
Sylvain
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Yeah this is why I post code onto websites like this. My ftp'd files never went over a meg so i never hit this scenario.
My solution was as I call it a hack type way of solving the problem so replace the Timeup code with public void Timeup(Object source, ElapsedEventArgs e) { if (LogTimer != null) { Console.WriteLine("LogTimer - timeout " + fileName); try { bool bPeak = false; using (StreamReader sr = new StreamReader(fullPath)) { while (sr.Peek() >= 0) { bPeak = true; break; } } if (!bPeak) ResetTimer(); else { LogTimer.Stop(); OnTimer(fileName); LogTimer = null; }
} catch { ResetTimer(); } } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
I really love this solution. It's exactly what I have been looking for. I tweaked a few things (mostly for naming conventions and my own needs) but one worth sharing is the removal of the file from the hashtable just before firing the event to the monitor's client.
Of course, this eliminates the ability to use the GetItem method from the client code. I get around this by bubbling up the original FileSystemEventArgs object. Then I don't have to query the object to get the file information object.
This tweak solved the one problem I had with the code in testing a copy operation to the watched directory of 1000 files that were 1K in size. Seems the time it took to look up a key using the Contains method of the Hashtable as the table filled up caused just enough performance degredation that my test would fail and I'd miss about five or six files. Once I started removing the object from the Hashtable when I bubbled the event, it caught every file even when I pushed as many files into the directory as my 3GHz P4 with fast SATA drives could push.
Great job on solving a common problem with an uncommon, but highly effective solution.
-Tyler
Tyler Jensen Right tools, right methods!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks Tyler
I'll checkout your test and update the code. My problem involved very large files being pushed at slow rates so my performance considerations could well need some tweaking. I'll get back to you as soon as I can.
Rich
Hey man the universe is just a cosmic bubble!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I set up this ( very useful ) code to watch for ftp'd files and then do some operations on the data.
What I noticed is that you do:
watcher.Created += new FileSystemEventHandler(OnChanged); watcher.Changed += new FileSystemEventHandler(OnChanged);
Copies to the monitored directory and also ftp's to the monitored directory are executed twice, so the PostEvent was fired twice and my processing code as well.
I removed the .Changed handler and it seems to work ok now.
Question: why did you pass the same OnChanged method as a handler for both .Created and .Changed ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
In the OnChanged code I differentiate between the two events. I would have split the events into two seperate functions if the processing code was much larger.
It should not have fired two PostEvents, the Changed event doesn't created a new FileObject it just Resets the timer. There's something else wrong if two PostEvents happened.
Rich
Hey man it's just a cosmic bubble!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I am trying to create a save feature in C#.net. So far I have created the save file Dialog control in visual C#.net... The save file dialog control doesn't actually save a file; it is used to enable a user to specify a filename to save. I am wondering what I need to do with the filename returned by the control to actually save the file.
thanks!
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
I came across this site... http://www.dotnet247.com/247reference/msgs/41/207923.aspx
Here's the code I used:
FileSystemWatcher fswDetection = new FileSystemWatcher(@"d:\Work\Incoming\Detections");
fswDetection.IncludeSubdirectories = false; fswDetection.EnableRaisingEvents = true; fswDetection.NotifyFilter = NotifyFilters.LastWrite;
fswDetection.Changed += new FileSystemEventHandler(OnChanged);
fswDetection.WaitForChanged(WatcherChangeTypes.Created);
It works!
|
| Sign In·View Thread·PermaLink | 3.75/5 (3 votes) |
|
|
|
 |