Class ZipFileProvider
Provides access to files contained in a .zip file to a FileModule.
Implements
Namespace: EmbedIO.Files
Syntax
public class ZipFileProvider : IDisposable, IFileProvider
Constructors
ZipFileProvider(Stream, Boolean)
Initializes a new instance of the ZipFileProvider class.
Declaration
public ZipFileProvider(Stream stream, bool leaveOpen = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream that contains the archive. |
| Boolean | leaveOpen | true to leave the stream open after the web server is disposed; otherwise, false. |
ZipFileProvider(String)
Initializes a new instance of the ZipFileProvider class.
Declaration
public ZipFileProvider(string zipFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| String | zipFilePath | The zip file path. |
Properties
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 ZipFileProvider 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>> |