Class FileSystemProvider
Provides access to the local file system to a FileModule.
Implements
Namespace: EmbedIO.Files
Syntax
public class FileSystemProvider : IDisposable, IFileProvider
Constructors
FileSystemProvider(String, Boolean)
Initializes a new instance of the FileSystemProvider class.
Declaration
public FileSystemProvider(string fileSystemPath, bool isImmutable)
Parameters
Type | Name | Description |
---|---|---|
String | fileSystemPath | The file system path. |
Boolean | isImmutable | true if files and directories in
|
Remarks
OSX doesn't support isImmutable
will be always true.
Properties
FileSystemPath
Gets the file system path from which files are retrieved.
Declaration
public string FileSystemPath { get; }
Property Value
Type | Description |
---|---|
String |
IsImmutable
Gets a value indicating whether the files and directories provided by this instance will never change.
Declaration
public bool IsImmutable { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Finalize()
Finalizes an instance of the FileSystemProvider class.
Declaration
protected void Finalize()
GetDirectoryEntries(String, IMimeTypeProvider)
Returns an enumeration of the entries of a directory.
Declaration
public IEnumerable<MappedResourceInfo> GetDirectoryEntries(string providerPath, IMimeTypeProvider mimeTypeProvider)
Parameters
Type | Name | Description |
---|---|---|
String | providerPath | The provider-specific path for the directory. |
IMimeTypeProvider | mimeTypeProvider | An IMimeTypeProvider interface to use for determining the MIME type of files. |
Returns
Type | Description |
---|---|
IEnumerable<MappedResourceInfo> | An enumeration of MappedResourceInfo objects identifying the entries
in the directory identified by |
MapUrlPath(String, IMimeTypeProvider)
Maps a URL path to a provider-specific path.
Declaration
public MappedResourceInfo MapUrlPath(string path, IMimeTypeProvider mimeTypeProvider)
Parameters
Type | Name | Description |
---|---|---|
String | path | The URL path. |
IMimeTypeProvider | mimeTypeProvider | An IMimeTypeProvider interface to use for determining the MIME type of a file. |
Returns
Type | Description |
---|---|
MappedResourceInfo | A provider-specific path identifying a file or directory,
or null if this instance cannot provide a resource associated
to |
OpenFile(String)
Opens a file for reading.
Declaration
public Stream OpenFile(string providerPath)
Parameters
Type | Name | Description |
---|---|---|
String | providerPath | The provider-specific path for the file. |
Returns
Type | Description |
---|---|
Stream | A readable |
Start(CancellationToken)
Signals a file provider that the web server is starting.
Declaration
public void Start(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A |
Events
ResourceChanged
Occurs when a file or directory provided by this instance is modified or removed.
The event's parameter is the provider-specific path of the resource that changed.
Declaration
public event Action<string>? ResourceChanged
Event Type
Type | Description |
---|---|
Nullable<Action<String>> |