Click or drag to resize
GDStorageFileCopyAsync Method (IGDStorageFolder, String)
Creates a copy of the file in the specified folder and renames the copy.

Namespace:  GD
Assembly:  GD (in GD.dll) Version: 255.255.255.255
Syntax
public IAsyncOperation<GDStorageFile> CopyAsync(
	IGDStorageFolder destinationFolder,
	string desiredNewName
)

Parameters

destinationFolder
Type: GDIGDStorageFolder
The destination folder where the copy is created.
desiredNewName
Type: SystemString
The new name for the copy of the file created in the destinationFolder.

Return Value

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

Implements

IGDStorageFileCopyAsync(IGDStorageFolder, String)
Exceptions
ExceptionCondition
AccessDeniedException(C# equivalent: System.UnauthorizedAccessException) Secure storage was remotely wiped.
Exception Name you specify is invalid. To handle all the ways the specified name could be invalid, you must catch all of these exceptions:
E_FAIL
ERROR_INVALID_NAME
ERROR_ALREADY_EXISTS
ERROR_INVALID_PARAMETER
Remarks
This method uses the FailIfExists value from the NameCollisionOption enumeration by default. That is, this method raises an exception if a file with the same name already exists in the destination folder. If you want to handle a file name collision in a different way, call the CopyAsync(IGDStorageFolder, String, NameCollisionOption) method.
Examples
The following example shows how to get the folder that has the specified absolute path in the SDK secure storage.
using GD;

// Get the app's secure folder.
GDStorageFolder secureFolder = GDWindows.Instance.SecureFolder;
GDStorageFolder folder = await secureFolder.GetFolderAsync("folder");

// Create a sample file in the secure folder.
GDStorageFile newFile = await secureFolder.CreateFileAsync("test.txt");

// Copy the file to the destination folder.
// Raise an exception if the file already exists.
GDStorageFile copiedFile = await newFile.CopyAsync(folder);
See Also