Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Greetings;

I have a requirement where I have to create a program which watches a folder. The user will input files into the folder which the program will pick up from time to time and process it. The catch here is if a user is copying files during the time the program begins processing the folder, the program should stop and try again some time later. For example if user is copying 5 file into the target folder and has only finished copy 2 at the time program wakes up, the program should not process the 2 files.

In order to do this I require to find out if copy process is in progress on the folder. I would be very grateful if some one could point me to right direction in regards to how I will be able to achieve this using C# or Vb.net.

Thanks and Regards

Kiran
Posted

File System watcher may helps you..,

Go through the below link..,

FileSystemWater in C#[^]
 
Share this answer
 
Comments
kiran krishh 28-Oct-10 10:41am    
First of all, my sincerest thank you for taking time for my issue. I have already tried to using the Create event the FileSystemWatcher class. However the event is fired when ever a file gets copied to the folder. It does not wait for the entire copy process to complete. Also I searched for a property or event in FileSystemWatcher which would tell me if the copy process is still in progress.
To better describe the scenario let me give you a example. Suppose if there are three files f1, f2 and f3. The user will copy these files into target folder and once these file has been copied the files have to be process in the order of f1, f2 and f3. If user copies only file f1 and f3 then the files will be process in the following order : f1 then f3.
When I tried using FileSystemWatcher Create event, the event was fired for each file and cannot be used to determine if all the files have been copied in by the operation system.
Toli Cuturicu 28-Oct-10 11:57am    
Oh, I see... It is the water that pours in your File System... Ok, then!
find a method to determine that the file is being used by other program.
 
Share this answer
 
Use a FileSystemWatcher then!
 
Share this answer
 
v2
Comments
kiran krishh 28-Oct-10 10:39am    
First of all, my sinceritest thank you for taking time for my issue.

I have already tried to using the Create event the FileSystemWatcher class. However the event is fired when ever a file gets copied to the folder. It does not wait for the entire copy process to complete. Also I searched for a property or event in FileSystemWatcher which would tell me if the copy process is still in progress. To better describe the scenario let me give you a example.

Suppose if there are three files f1, f2 and f3. The user will copy these files into target folder and once these file has been copied the files have to be process in the order of f1, f2 and f3. If user copies only file f1 and f3 then the files will be process in the following order : f1 then f3.

When I tried using FileSystemWatcher Create event, the event was fired for each file and cannot be used to determine if all the files have been copied in by the operation system.

Hope that makes sense to you :)
Toli Cuturicu 28-Oct-10 11:56am    
Yes, I got you. Sorry, but I can't help you with this. Hope someone can and will help you. Good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900