Class File
Provide utility methods for files.
Inheritance
Namespace: CarinaStudio.IO
Assembly: CarinaStudio.AppBase.Core.dll
Syntax
public static class File : object
Methods
| Improve this Doc View SourceExistsAsync(Nullable<String>, CancellationToken)
Check whether the given file exists or not asynchronously.
Declaration
public static Task<bool> ExistsAsync(string? path, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
path | Path to the file. |
Cancellation |
cancellationToken | Cancellation. |
Returns
Type | Description |
---|---|
Task<System. |
Task of checking existence of file. |
TryOpen(String, FileMode, FileAccess, Int32, out Nullable<FileStream>)
Try opening file with given timeout.
Declaration
public static bool TryOpen(string fileName, FileMode mode, FileAccess access, int timeoutMillis, out FileStream? stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
fileName | File name. |
File |
mode | Mode to open file. |
File |
access | Desired access. |
System. |
timeoutMillis | Timeout in milliseconds. |
System. |
stream | Opened stream. |
Returns
Type | Description |
---|---|
System. |
True if file opened successfully in given timeout. |
TryOpenRead(String, Int32, out Nullable<FileStream>)
Try opening file for reading with given timeout.
Declaration
public static bool TryOpenRead(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
fileName | File name. |
System. |
timeoutMillis | Timeout in milliseconds. |
System. |
stream | Opened stream. |
Returns
Type | Description |
---|---|
System. |
True if file opened successfully in given timeout. |
TryOpenReadWrite(String, Int32, out Nullable<FileStream>)
Try opening file for reading and writing with given timeout.
Declaration
public static bool TryOpenReadWrite(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
fileName | File name. |
System. |
timeoutMillis | Timeout in milliseconds. |
System. |
stream | Opened stream. |
Returns
Type | Description |
---|---|
System. |
True if file opened successfully in given timeout. |
TryOpenWrite(String, Int32, out Nullable<FileStream>)
Try opening file for writing with given timeout.
Declaration
public static bool TryOpenWrite(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
fileName | File name. |
System. |
timeoutMillis | Timeout in milliseconds. |
System. |
stream | Opened stream. |
Returns
Type | Description |
---|---|
System. |
True if file opened successfully in given timeout. |