| GDStorageFileCopyAsync Method (IGDStorageFolder, 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:
GD
Assembly:
GD (in GD.dll) Version: 255.255.255.255
Syntax public IAsyncOperation<GDStorageFile> CopyAsync(
IGDStorageFolder destinationFolder,
string desiredNewName,
NameCollisionOption option
)
public:
virtual IAsyncOperation<GDStorageFile^>^ CopyAsync(
[InAttribute] IGDStorageFolder^ destinationFolder,
[InAttribute] String^ desiredNewName,
[InAttribute] NameCollisionOption^ option
) sealed
function CopyAsync(destinationFolder, desiredNewName, option);
Parameters
- destinationFolder
- Type: GDIGDStorageFolder
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: Windows.StorageNameCollisionOption
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:
IAsyncOperationGDStorageFileWhen this method completes, it returns a
GDStorageFile that represents the copy of the file created in the
destinationFolder.
Implements
IGDStorageFileCopyAsync(IGDStorageFolder, String, NameCollisionOption)Exceptions Exception | Condition |
---|
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;
...
GDStorageFolder secureFolder = GDWindows.Instance.SecureFolder;
string newFileName = "test.txt";
GDStorageFile newFile = await tempFolder.CreateFileAsync(newFileName);
GDStorageFolder folder = secureFolder.GetFolderAsync("folder");
string renamedFileName = "renamed_test.txt";
GDStorageFile copiedFile =
await newFile.CopyAsync(folder,
renamedFileName, NameCollisionOption.ReplaceExisting);
See Also