FileSystem.FileCopy(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Copies a file. The FileSystem gives you better productivity and performance in file I/O operations than FileCopy. See CopyFile(String, String) for more information.
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)
Parameters
- Source
- 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.
- Destination
- String
Required. A string expression that specifies the destination file name. Destination may include the directory or folder, and drive, of the destination file.
Exceptions
Source or Destination is invalid or not specified.
File is already open.
File does not exist.
Examples
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.
Remarks
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.