Class FileStream
A file stream.
Inheritance
Implements
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class FileStream : object, IFileStream
Constructors
FileStream(String)
Initializes a new instance of the FileStream class.
Declaration
public FileStream(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path. |
Properties
Length
Gets the file length (must be opened first).
Declaration
public long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Path
Gets the path.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
System.String |
Position
Gets or sets the position in the file.
Declaration
public long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Methods
Close()
Closes the file.
Declaration
public void Close()
Delete(String)
Deletes the specified file.
Declaration
public static bool Delete(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file path. |
Returns
Type | Description |
---|---|
System.Boolean | True if file is deleted, false if exception occured. |
Exists()
Returns a boolean value indicating whether the file exists.
Declaration
public bool Exists()
Returns
Type | Description |
---|---|
System.Boolean |
Flush()
Flushes the file contents.
Declaration
public bool Flush()
Returns
Type | Description |
---|---|
System.Boolean |
Open(FileStreamAccess)
Opens the file.
Declaration
public void Open(FileStreamAccess access)
Parameters
Type | Name | Description |
---|---|---|
FileStreamAccess | access | The access requirement. |
Read(Byte[], Int32, Int32)
Reads data from the file.
Declaration
public int Read(byte[] data, int index, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The buffer to fill with data from the file. |
System.Int32 | index | The index at which to start writing. |
System.Int32 | length | The maximum number of bytes to read. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes read from the file. |
Write(Byte[], Int32, Int32)
Writes data to the file.
Declaration
public bool Write(byte[] data, int index, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data to write to the file. |
System.Int32 | index | The index at which to start reading. |
System.Int32 | length | The number of bytes to write. |
Returns
Type | Description |
---|---|
System.Boolean |
|
WriteTo(Int32, Byte[], Int32, Int32)
Writes data to the file.
Declaration
public bool WriteTo(int location, byte[] data, int index, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | data | The data to write to the file. |
System.Int32 | index | The index at which to start reading. |
System.Int32 | length | The number of bytes to write. |
Returns
Type | Description |
---|---|
System.Boolean |
|