Skip to content

Storage FileStorage

github-actions[bot] edited this page Dec 4, 2026 · 1 revision

FileStorage

FileStorage, in the Storage.Files namespace, is the abstract base class for saving files. Pass the file's bytes and original name to Save. The provider chooses the storage location and returns it as a string.

Size and extension limits

  • maxFileSizeBytes is an exclusive limit. A limit of 1024 accepts up to 1023 bytes. A limit of zero rejects even an empty file.
  • AllowedExtensions is a mutable list. The check uses the final extension of the original name and ignores case. For example, either png or .png accepts photo.PNG.
  • An empty list permits every extension, including names with no extension. When the list contains entries, the file must have a matching extension.

Save(byte[] content, string fileName) throws InvalidDataException if the content reaches or exceeds the size limit or the extension is disallowed. Null content raises ArgumentNullException.

Deletion

Pass the location returned by Save to Delete(string path). The method deletes the file if it exists. An invalid storage path raises ArgumentException.

Related topics

LocalFileStorage · Class source · User manual

Clone this wiki locally