how to know if File.Copy is finished

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I have some trouble opening .dwg files. First of all I copy them to a folder on a shared web server and then I use javascript to open AutoCad and try to open the files. It returns an "File not found" error. It works in my dev environment but not at my customer.

I wonder if it could have something to do with the File.Copy method (they are large files and takes several seconds to be copied to the web-server). My question is:

Does the File.Copy method return when the WHOLE file is copied, or could it be that the application run through the code to the part where it tries to start the AutoCad before all the files are actually finished copying? In that case, how could I stall the AutoCad-start until all files are in place?

Hope you understand my question.
/Miro
 
I found no information to indicate File.Copy - or it's underlying
Win32 methods would return before the file was complete. Driver-level
caching (or similar) aside, I would be surprised if it *wasn't*
complete when the call returned. I did several tests, monitoring the
file activity and saw nothing to contradict this.

However, as David mentioned, a FileSysetmWatcher could be used to
guarantee the fact.

The key test would be to put a Thread.Sleep() or other pause after the
File.Copy() but before the auto-cad launching. If this fixed the
problem, then I'm (cough) wrong and the files are not committed when
the Copy() method returned.
 
Back
Top