Click or drag to resize

ExtensionsDirectoryInfoCopyAsync Method (FileInfo, DirectoryInfo, String, NameCollisionOption)

Creates a copy of the file in the specified folder and renames the copy. This method also specifies what to do if a file with the same name already exists in the destination folder.

Namespace:  Cauldron
Assembly:  Cauldron (in Cauldron.dll) Version: 3.2.0.2
Syntax
public static Task<FileInfo> CopyAsync(
	this FileInfo source,
	DirectoryInfo destinationFolder,
	string desiredNewName,
	NameCollisionOption option
)

Parameters

source
Type: System.IOFileInfo
The file to be copied
destinationFolder
Type: System.IODirectoryInfo
The destination folder where the copy of the file is created.
desiredNewName
Type: SystemString
The new name for the copy of the file created in the destinationFolder.
option
Type: CauldronNameCollisionOption
One of the enumeration values that determines how to handle the collision if a file with the specified desiredNewName already exists in the destination folder.

Return Value

Type: TaskFileInfo
When this method completes, it returns a FileInfo that represents the copy of the file created in the destinationFolder.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type FileInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullExceptiondesiredNewName is null
ArgumentExceptiondesiredNewName is empty
IOExceptionIf file already exists. Only on FailIfExists
See Also