Click or drag to resize
FileInfoCopyTo Method (String, Boolean)
Copies an existing file to a new file, allowing the overwriting of an existing file.

Namespace: Alphaleonis.Win32.Filesystem
Assembly: AlphaFS (in AlphaFS.dll) Version: 2.0
Syntax
public FileInfo CopyTo(
	string destinationPath,
	bool overwrite
)

Parameters

destinationPath
Type: SystemString
The name of the new file to copy to.
overwrite
Type: SystemBoolean
to allow an existing file to be overwritten; otherwise, .

Return Value

Type: FileInfo

Returns a new file, or an overwrite of an existing file if overwrite is .

If the file exists and overwrite is , an IOException is thrown.

Exceptions
ExceptionCondition
ArgumentExceptiondestinationPath contains invalid characters, is empty, or contains only white spaces.
ArgumentNullExceptiondestinationPath is .
DirectoryNotFoundException.
FileNotFoundException.
IOException.
NotSupportedException.
UnauthorizedAccessException.
Remarks

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

See Also