Interface IFile
Provides properties and methods for the reading, writing, copying, deletion and moving of file.
Namespace: Terrasoft.File.Abstractions
Assembly: Terrasoft.File.Abstractions.dll
Syntax
public interface IFile
Properties
CreatedOn
Gets or sets the creation time of the current file.
Declaration
DateTime CreatedOn { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
Exists
Gets a value indicating whether a file exists.
Declaration
bool Exists { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
FileLocator
Gets the file locator assigned with the current instance of the IFile type.
Declaration
IFileLocator FileLocator { get; }
Property Value
Type | Description |
---|---|
IFileLocator |
Length
Gets the size, in bytes, of the current file.
Declaration
long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
ModifiedOn
Gets or sets the modification time of the current file.
Declaration
DateTime ModifiedOn { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
Name
Gets or sets the name of the file.
Declaration
string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
CopyAsync(IFile)
Asynchronous copies the current file.
Declaration
Task CopyAsync(IFile target)
Parameters
Type | Name | Description |
---|---|---|
IFile | target | File to copy. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous copy operation. |
DeleteAsync()
Asynchronous deletes the current file.
Declaration
Task DeleteAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous delete operation. |
GetAttribute<TValue>(String, TValue)
Returns the attribute value for the current file.
Declaration
TValue GetAttribute<TValue>(string name, TValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Attribute name. |
TValue | defaultValue | Attribute default value to return. |
Returns
Type | Description |
---|---|
TValue |
Type Parameters
Name | Description |
---|---|
TValue |
MoveAsync(IFile)
Asynchronous moves the current file.
Declaration
Task MoveAsync(IFile target)
Parameters
Type | Name | Description |
---|---|---|
IFile | target | Destination file. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous move operation. |
ReadAsync()
Asynchronous reads the current file content
Declaration
Task<Stream> ReadAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | A task representing the asynchronous read operation. |
SaveAsync()
Asynchronous saves the current file metadata.
Declaration
Task SaveAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous save operation. |
SetAttribute<TValue>(String, TValue)
Sets the attribute value for the current file.
Declaration
void SetAttribute<TValue>(string name, TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Attribute name. |
TValue | value | Attribute value. |
Type Parameters
Name | Description |
---|---|
TValue |
WriteAsync(Stream, FileWriteOptions)
Asynchronous writes the current file content.
Declaration
Task WriteAsync(Stream stream, FileWriteOptions writeOptions)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream that represents the current file content. |
FileWriteOptions | writeOptions | Options to write file. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous write operation. |