How To Force Copy One File To Another

  • Thread starter Thread starter Christopher Lusardi
  • Start date Start date
C

Christopher Lusardi

If I want to copy one file to another how do I do that? I want to do
this even if the second file already exists.

Thanks,
Christopher Lusardi
 
Try

File.Copy ( "C:\ahhh\ohhh\eeeee\bbboooo\myfile.poo",
"C:\ahhh\ohhh\eeeee\aaaaeeee\myfile.poo", True )

Finally

End Try
 
To force copy in VB, I use:
fso.FileCopy src dest true

Where:
fso - file system object I created earlier
..FileCopy - the command to copy a file
src - variable w/ the source file full path/name
dest - variable w/ the destination file full path and name
true - Boolean to determine overwrite status.

One problem this could run into is permissions, another is if one of
the files is in use by another process.
 
Except that this is Vb.Net and the FileSystemObject is obsolete. Just
use the classes in the System.IO namespae as Robin suggested.
 
Back
Top