Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying/Moving a file that is being written to?

Status
Not open for further replies.

VoodooRageII

Programmer
Aug 25, 2002
14
0
0
US
I have a procedure that is going through and checking to see if a file exists in a destination directory and if not then copying the file from the source directory. The problem that only happens very occasionally is that files are constantly being copied to the source directory. Occasionally I get an IO.SYSTEM error where I think that the procedure is seeing and trying to copy the file that is being created. Is there anyway to check to see if a file is open (being created) where I can skip that file if it is being accessed?

Thanks for any help in this problem!

 
I would put it in try-catch:
Code:
Try
    IO.File.Copy(SourceFileName, TargetFileName)
Catch
    'Do nothing, or tell the system that the file cannot be copied
End Try
Regards,
mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top