You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Loading files

There are two overloads of the LoadFileAsync method used to load a single or multiple files in a single call.

Syntax

Task<FileHeader> LoadFileAsync(string path);

Parameters
path string The full file path to load
Return Value
Task<FileHeader> The file instance represented by the FileHeader object or null if a file does not exist.


Task<FileHeader[]> LoadFileAsync(IEnumerable<string> paths);

Parameters
paths IEnumerable<string> The collection of the file paths to load
Return Value
Task<FileHeader[]> The array of file instances, each represented by theFileHeader object or null if a file does not exist.

File headers

Note that the load method does not download file content. It fetches only the header, which is a basic session entity object.

Example I

FileHeader file = await session.LoadFileAsync("/movies/intro.avi");

Example II

If you pass multiple paths, the returned array contains headers in exactly the same order as the given paths. If a file does not exist, the value at the appropriate position in the array will be null.

FileHeader[] files = await session.LoadFileAsync(new[]
{
	"non-existing-file", "/movies/intro.avi"
}); // will return [null, FileHeader] array