Represents a file. Not all implementations will support all
available methods and may throw
System.NotSupportedException
.
- Namespace
- Statiq
.Common - Interfaces
- Implementing Types
graph BT
Type-.->Interface0["IFileSystemEntry"]
click Interface0 "/api/Statiq.Common/IFileSystemEntry"
Type-.->Interface1["IDisplayable"]
click Interface1 "/api/Statiq.Common/IDisplayable"
Type-.->Interface2["IContentProviderFactory"]
click Interface2 "/api/Statiq.Common/IContentProviderFactory"
Type-.->Interface3["ICacheCode"]
click Interface3 "/api/Statiq.Common/ICacheCode"
Type["IFile"]
class Type type-node
Implementing0["TestFile"]-.->Type
click Implementing0 "/api/Statiq.Testing/TestFile"
Syntax
public interface IFile : IFileSystemEntry, IDisplayable, IContentProviderFactory, ICacheCode
Properties
Name | Property Type | Summary |
---|---|---|
Directory | IDirectory |
Gets the directory of the file.
|
Length | long |
Gets the length of the file.
|
MediaType | string |
Gets the media type of the file.
|
Path | NormalizedPath |
Gets the path to the file.
|
Methods
Name | Return Value | Summary |
---|---|---|
Delete |
void |
Deletes the file.
|
Open |
Stream |
Opens the file for reading and writing. This will either create the file
if it doesn't exist or overwrite it if it does.
|
OpenAppend |
Stream |
Opens the file for writing. This will either create the file
if it doesn't exist or append to it if it does.
|
OpenRead |
Stream |
Opens the file for reading. If it does not exist, an exception will be thrown.
|
OpenText |
TextReader |
Opens the file for reading as text. If it does not exist, an exception will be thrown.
|
OpenWrite |
Stream |
Opens the file for writing. This will either create the file
if it doesn't exist or overwrite it if it does.
You must manually call
System.IO.Stream.SetLength(System.Int64)
when done to ensure previously existing data is truncated.
|
ReadAllBytesAsync |
Task |
Reads all bytes from the file.
|
ReadAllTextAsync |
Task |
Reads all text from the file.
|
Refresh |
void |
Refreshes any cached information about the file.
|
WriteAllBytesAsync |
Task |
Writes the specified bytes to a file.
|
WriteAllTextAsync |
Task |
Writes the specified text to a file.
|