System. File Copy(String, String) Method
public: static void FileCopy(System::String ^ Source, System::String ^ Destination);
public static void FileCopy (string Source, string Destination);
static member FileCopy : string * string -> unit
Public Sub FileCopy (Source As String, Destination As String)
Required. A string expression that specifies the name of the file to be copied.
Source may include the directory or folder, and drive, of the source file.
Required. A string expression that specifies the destination file name.
Destination may include the directory or folder, and drive, of the destination file.
Destination is invalid or not specified.
File is already open.
File does not exist.
This example uses the
FileCopy function to copy one file to another. For purposes of this example, assume that
SrcFile is a file that contains data.
Dim SourceFile, DestinationFile As String SourceFile = "SRCFILE" ' Define source file name. DestinationFile = "DESTFILE" ' Define target file name. FileCopy(SourceFile, DestinationFile) ' Copy source to target.
If you try to use the
FileCopy function on a currently open file, an error occurs.
FileCopy requires full trust to work on the local drive.