see on GitHub

Manage file systems

CreateFileSystemAsync

This method is used to create a new file system. If the file system already exists then it will throw an exception.

Syntax

Task CreateFileSystemAsync(FileSystemDocument filesystemDocument, string newFileSystemName = null);

Parameters
filesystemDocument FileSystemDocument The document containing all configuration options for a new file system (e.g. active bundles, name/id, data path)
newFileSystemName string The new file system name, if null then current file system name will be used (store.AsyncFilesCommands.FileSystem)

Return Value
Task A task that represents the asynchronous operation

Example

Let's create a new file system with Versioning bundle enabled:

await store.AsyncFilesCommands.Admin
	.CreateFileSystemAsync(new FileSystemDocument
	{
		Id = "Raven/FileSystems/NorthwindFS",
		Settings =
		{
			{ Constants.FileSystem.DataDirectory, "~/FileSystems/NorthwindFS" },
			{ Constants.ActiveBundles, "Versioning" }
		}
	}, "NorthwindFS");

CreateOrUpdateFileSystemAsync

This method creates a new file system or updates the configuration of already existing one according to the specified document.

Task CreateOrUpdateFileSystemAsync(FileSystemDocument filesystemDocument, string newFileSystemName = null);

Parameters
filesystemDocument FileSystemDocument The document containing all configuration options for a new file system (e.g. active bundles, name/id, data path)
newFileSystemName string The new file system name, if null then current file system name will be used (store.AsyncFilesCommands.FileSystem)

Return Value
Task A task that represents the asynchronous operation

EnsureFileSystemExistsAsync

Instead of calling the CreateOrUpdateFileSystemAsync method, you can use this one to make sure that file system exists. If there is no such file system, it will be created with default settings.

Task EnsureFileSystemExistsAsync(string fileSystem);

Parameters
fileSystem string The file system name

Return Value
Task A task that represents the asynchronous operation

Example

await store.AsyncFilesCommands.Admin
		.EnsureFileSystemExistsAsync("NorthwindFS");

DeleteFileSystemAsync

This method is used to delete a file system from a server, with a possibility to remove its all data from the hard drive.

Task DeleteFileSystemAsync(string fileSystemName = null, bool hardDelete = false);

Parameters
fileSystemName string The name of a file system to delete, if null then current file system name will be used (store.AsyncFilesCommands.FileSystem)
hardDelete bool Determines if all data should be removed (data files, indexing files, etc.). Default: false

Return Value
Task A task that represents the asynchronous delete operation

Example

The below code deletes the current file system together with its data on the hard drive:

await store.AsyncFilesCommands.Admin
		.DeleteFileSystemAsync(hardDelete: true);