Method CopyFile
CopyFile(string, string, bool, int)
Copies a file from a source path to a destination path. This method uses low-level file streams instead of File.Copy (which uses Kernel32.CopyFileEx internally) to make it more compatible with file system virtualization methods which often(at least 2 of them) forget to hook them
Declaration
public static FileInfo CopyFile(string sourcePath, string destinationPath, bool overwrite, int bufferSize = 524288)
Parameters
Type | Name | Description |
---|---|---|
string | sourcePath | The path of the source file to be copied. |
string | destinationPath | The path to where the file should be copied. |
bool | overwrite | A boolean value indicating whether an existing file at the destination path should be overwritten. If set to false and a file exists, an exception will be thrown. |
int | bufferSize | Buffer size, most SSDs prefer larger buffer(512KB+) |
Returns
Type | Description |
---|---|
FileInfo |
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the destination file already exists and overwrite parameter is set to false, or any other IO error occurs. |