Skip to main content

Registering renames

#Registering renames

Use the RegisterRename method to rename a file.

void RegisterRename(string sourceFile, string destinationFile, Etag etag = null);
void RegisterRename(FileHeader sourceFile, string destinationFile, Etag etag = null);
Parameters
sourceFilestringThe full file path to change
sourceFileFileHeaderThe file that you want to rename represented by the FileHeader
destinationFilestringThe new file path
etagEtagThe current file Etag, used for concurrency checks (null will skip the check)

If the requested file does not exist in the file system, the FileNotFoundException will be thrown by the SaveChangesAsync.

Rename and move is basically the same operation. Directories in RavenFS are a virtual concept, which relies on the file paths. So if you want to move a file into a different "directory", simply rename it.

Example

session.RegisterRename("/movies/intro.avi", "/movies/introduction-to-ravenfs.avi");

await session.SaveChangesAsync();