473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copying a file after the "Created" event with FileSystemWatcher

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
happens.

Is there anyway to set a NotifyFilter to respond ONLY when the file
has been "completely" created?
Nov 21 '05 #1
1 1963
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.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin | last post by:
When I open MySQL Control Center, it shows "server properties" window when the server is selected on the left pane. One of the property is "date created". I have not found this variable in server...
2
by: Phil Galey | last post by:
I have a FileSystemWatcher that triggers when a PDF file is created. However, the creation of the PDF file is about a 7 or 8 second process ... I cannot refer to the file during that time because...
3
by: Florida Development | last post by:
I have the need to monitor a directory for the arrival of files and then to run some processing on those new files. This is easy enough conceptually, the problem I have is that I get an event to...
2
by: Tommy Vercetti | last post by:
I am working on a Managed C++ project and I get the following error: TestThread.cpp(3) : error C2859: c:\projects\ProjectName\debug\vc70.pdb is not the pdb file that was used when this...
3
by: Tomdhu | last post by:
As a Newbie I've picked up a heap of tips and tricks from this NG but I have been battling to get the current user's Netwok Login ID recorded on a form at the time a new record is created or...
0
by: Silver Oak | last post by:
Hi, I'm experimenting with FileSystemWatcher but it doesn't seem like it fires when a new file is created. Everytime I create a new file, it fires Changed event i.e. Case...
8
by: MikeJ | last post by:
In my office, we have workstations with standard Win 2000 images (OS plus standard apps like Office, etc.) as developers, we then install our development tools on top of those images. other...
2
by: Ripley | last post by:
I am trying to find out exactly when this even fires when a file is "created" in a directory being monitored. That is, for a large file, that takes several minutes to upload, will the created event...
0
by: Andy B | last post by:
When I ran the asp.net admin tool to setup web application settings, I get the following notice when I went to profile and chose to use a single provider for all features: "The provider wasn't...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.