Skip to main content

Commands: RenameAsync

Syntax

#Commands: RenameAsync

RenameAsync is used to change the file name.

Task RenameAsync(string currentName, string newName, Etag etag = null);
Parameters
currentNamestringThe name of the file that you want to change
newNamestringThe new name of a file
etagEtagThe current file etag used for concurrency checks (null skips check)

Return Value
TaskA task that represents the asynchronous rename operation

Example

await store
.AsyncFilesCommands
.RenameAsync(
"/movies/intro.avi",
"/movies/introduction.avi"
);

Note that a file move operation is basically the rename too (directories are just a virtual concept). In order to move intro.avi file from /movies folder to /movies/examples, we need to use the following code:

await store
.AsyncFilesCommands
.RenameAsync(
"/movies/intro.avi",
"/movies/examples/intro.avi"
);

If the file rename is requested, RavenFS needs to update collection of usages of this file's pages. In order to make RavenFS resistant to restarts in the middle of the rename operation, use a a periodic task, which ensures that all requested renames will be finished after the restart.