By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

Copying a file after the "Created" event with FileSystemWatcher

P: n/a
Given a scenario where I'm monitoring a folder, once the file has been
created, I'd like to have it relocated to another folder via the
File.Copy() method.

My problem occurs when I paste a 600mb+ file into the folder I'm
monitoring. I use this magnitude of a size in order to guarantee it'll
work for smaller files.

The "created" event occurs before the file is actually completely
copied into the folder, so when I try to do File.Copy(), nothing

Is there anyway to set a NotifyFilter to respond ONLY when the file
has been "completely" created?
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On 18 Oct 2004 07:17:29 -0700, Jason wrote:

Is there anyway to set a NotifyFilter to respond ONLY when the file
has been "completely" created?

Not to my knowledge. I have used two methods. The first method is to have
the file placed in the folder using a temporary name and then rename it to
the expected name. Then handle the Rename event of the FileSystemWatcher.

The second is when the Create event occurs, attempt to open the file
exclusively. If that fails, then the file is still being copied in. Keep
attempting to open the file in a loop until you are successful. Then you
can perform the file.copy.



To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.