0

Iam developing an application which will trigger events for file/folder creation.When i copy a folder with some files in it the event is trigerred when the copy operation is just started, that makes difficult for my function which executes on the event to work with the files inside since the files are not yet fully copied..So, how to find whether the contents(files/sub folder) in that copy folder is ready to use.i.e fully copied so that i can run my function after the complete folder is ready to use.

Thanks in advance..

  • So far as the file system is concerned, each file copy is an independent action. Your question essentially boils down to "how can my code predict the future about how some other piece of code is going to act?", since there's no way to know if the other piece of code (the piece doing the copying) is going to create *another* file after the current one. – Damien_The_Unbeliever May 17 '17 at 12:28
  • Possible duplicate of [C# FileSystemWatcher, How to know file copied completely into the watch folder](http://stackoverflow.com/questions/4277991/c-sharp-filesystemwatcher-how-to-know-file-copied-completely-into-the-watch-fol) – Knowledge Cube May 17 '17 at 12:28
  • "how can my code predict the future about how some other piece of code is going to act?" - liked it – Arunkumar Kathirvel May 17 '17 at 12:32
  • will try to change the logic..thanks – Arunkumar Kathirvel May 17 '17 at 12:32

1 Answers1

0

You can use the trigger as to check if the file is coming.If a certain time does not trigger then the copy is finished and you can get all file with Directory.GetFiles

Mehmet Topçu
  • 1
  • 1
  • 16
  • 31