If you have only one Adapter (Local/Azure BlobStorage/...) you can use the general usage.
Otherwise you should use the Multiple Adapters FileSystem API.
Write Files
await fileSystem.WriteAsync("path/to/file.txt", byteArray);
await fileSystem.WriteAsync("path/to/file.txt", stream);
// overwrite
await fileSystem.WriteAsync("path/to/file.txt", byteArray, overwrite:true);
await fileSystem.WriteAsync("path/to/file.txt", stream, overwrite:true);
// overwrite and/or cancellationToken
await fileSystem.WriteAsync("path/to/file.txt", byteArray, overwrite:true, cancellationToken: cancel);
await fileSystem.WriteAsync("path/to/file.txt", stream, overwrite:true, cancellationToken: cancel);
Read Files
// Read to byte array
byte[] byteArray = await fileSystem.ReadAllBytesAsync("path/to/file.txt");
byte[] byteArray = await fileSystem.ReadAllBytesAsync("path/to/file.txt", cancellationToken: cancel);
//Read to stream
await fileSystem.ReadToStreamAsync("path/to/file.txt", stream);
await fileSystem.ReadToStreamAsync("path/to/file.txt", stream, cancellationToken: cancel);
Check if a file exists
bool exists = await fileSystem.ExistsAsync("path/to/file.txt");
bool exists = await fileSystem.ExistsAsync("path/to/file.txt", cancellationToken: cancel);
NOTE: This only has consistent behaviour for files, not directories. Directories are less important in Flysystem, they're created implicitly and often ignored because not every adapter (filesystem type) supports directories.
Delete Files
await fileSystem.DeleteAsync("path/to/file.txt");
await fileSystem.DeleteAsync("path/to/file.txt", cancellationToken: cancel);
Rename Files
await fileSystem.RenameAsync("filename.txt", "newname.txt");
await fileSystem.RenameAsync("filename.txt", "newname.txt", cancellationToken: cancel);
Copy Files
//TODO await fileSystem.CopyAsync("filename.txt", "copy.txt");
//TODO await fileSystem.CopyAsync("filename.txt", "copy.txt", cancellationToken: cancel);
Get Mimetypes
string mimeType = await fileSystem.GetMimeTypeAsync("path/to/file.txt");
string mimeType = await fileSystem.GetMimeTypeAsync("path/to/file.txt", cancellationToken: cancel);
Get Timestamps
DateTime date = await fileSystem.GetLastModificationDateAsync("path/to/file.txt");
DateTime date = await fileSystem.GetLastModificationDateAsync("path/to/file.txt", cancellationToken: cancel);
Get File sizes (in bytes)
long sizeInBytes = await fileSystem.GetSizeAsync("path/to/file.txt");
long sizeInBytes = await fileSystem.GetSizeAsync("path/to/file.txt", cancellationToken: cancel);
Get Checksum
string checksum = await fileSystem.GetChecksumAsync("path/to/file.txt");
string checksum = await fileSystem.GetChecksumAsync("path/to/file.txt", cancellationToken: cancel);