I would use a System.Threading.Timer delegate (after the dir changed event)
to kick off every minuite or so to check the "CanWrite" status or catch the
open exception. This assumes the FTP process has opened the file with
exclusive write access, which it should. If it incorrectly opens the file
with shared read/write, then another solution may be needed.
--
William Stacey [MVP]
"Michael" <Mi*****@discussions.microsoft.comwrote in message
news:C8**********************************@microsof t.com...
| Hi,
| couldn't this cause an endless loop?
| Michael
|
| "ne***********@gmail.com" wrote:
|
| >
| Michael wrote:
| Hi,
| I have a little application that watches a FTP folder. When a file is
| uploaded, it takes that file and moves it to another folder on the
same
| server.
| Here are a couple of lines from my C# app:
|
| FileSystemWatcher watcher = new FileSystemWatcher();
| watcher.Created += new FileSystemEventHandler(OnChanged);
|
| My problem is that my folder watcher does not know when the file is
finish
| uploading. So if the file is 3mb my file watcher moves the file
before it is
| finished uploading, and the resulting new file in the new folder is
only like
| 24k.
|
| How can I "KNOW" when the file is finish uploading? Is there some
type of
| windows event I can watch?
|
| Thanks,
| Michael
| >
| I found this and thought it might help you:
| >
|
http://www.jasonstorch.com/
| >
| "If you have read my previous post on the FileSystemWatcher control, I
| posted code for a simple service that runs in the background ad copies
| files from one server to another. Basically, the fix is to add the
| following few lines of code to the create and change events:
| >
| while (!File.Exists(sample.file))
| {
| //keep looping until the file is unlocked.
| }"
| >
| The page has other code as well. Hope this helps.
| >
| >