473,698 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying a file after the "Created" event with FileSystemWatch er

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 1975
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 FileSystemWatch er.

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_lunch meat_[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
417
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 and status variables .... Does anyone know how to read this variable using MySQL SQL query or MySQL API (not file system, etc. ) ? Martin
2
2416
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 it does not yet exist. If I set up a loop using the Sleep API call, it loops forever and the software that creates the PDF file stops progressing and the file never finishes getting created. The FileSystemWatcher was triggered only on the...
3
1591
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 handle when the file is first created yet is not fully written to the disk yet. Is there some simple way (that will pass a code review) that I can determine when the file write to disk has been completed so I can do my processing? Thank you.
2
8467
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 precompiled header was created, recreate the precompiled header. Why would I get this error? How do I rebuild the precompiled header? Clean Solution, Rebuild Solution, don't help. If I manually delete the vc70.pdb, it doesn't seem to recompile. I've
3
3595
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 modified. I haven't implemented Access security, and want their Network Login ID. The network is running W2K server and all users have unique login ID's. I run A2K and I've found Dev Ashish's code at http://www.mvps.org/access/api/api0008.htm . I...
0
2435
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 WatcherChangeTypes.Created never fires. Please point out my mistake. Thanks. Michael
8
10991
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 developers in my office have installed VS8 and use it with no problems. however, on a new workstation that I recently got, I have installed VS8, and get this error whenever I try to access a C# project or create a new C# project: "Project 'XYZ'...
2
1728
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 fire as soon as the file starts loading, or only when the file has been completely uploaded. I can't find any documentation to this at MSDN. Thanks, Ripley
0
942
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 created". To reproduce: 1. In Visual Studio 2008, create a new web application. 2. Add a web.config file if one doesn't already exist. 3. In the <ConnectionStringselement, add a valid working connection string. Mine works but is left out for...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.