Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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 28-Oct-10 3:10am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

File System watcher may helps you..,
 
Go through the below link..,
 
FileSystemWater in C#[^]
  Permalink  
Comments
kiran krishh at 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 at 28-Oct-10 11:57am
   
Oh, I see... It is the water that pours in your File System... Ok, then!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

find a method to determine that the file is being used by other program.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use a FileSystemWatcher then!
  Permalink  
v2
Comments
kiran krishh at 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 at 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)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 8 Feb 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100