Windows Dev Center

IStorageItem.RenameAsync(String) method

Renames the current item.

Syntax


IAsyncAction RenameAsync(
  string desiredName
)

Parameters

desiredName

Type: System.String [.NET] | Platform::String [C++]

The desired, new name of the item.

Return value

Type: IAsyncAction

No object or value is returned by this method when it completes.

Remarks

If the name you specify is invalid, this method throws an exception. To handle all the ways the specified name could be invalid, you must catch all four of these exceptions:

E_INVALIDARG
E_FAIL
ERROR_FILENAME_EXCED_RANGE
ERROR_INVALID_NAME

 

If the file is deleted before the rename finishes, this method throws the ERROR_FILE_NOT_FOUND exception. You must also catch and handle this exception when you use this method.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

See also

IStorageItem
RenameAsync(String, NameCollisionOption)

 

 

Show:
© 2015 Microsoft