Class File
- Namespace
- CarinaStudio.IO
- Assembly
- CarinaStudio.AppBase.Core.dll
Provide utility methods for files.
public static class File
- Inheritance
-
File
- Inherited Members
Methods
ExistsAsync(string?, CancellationToken)
Check whether the given file exists or not asynchronously.
public static Task<bool> ExistsAsync(string? path, CancellationToken cancellationToken = default)
Parameters
pathstringPath to the file.
cancellationTokenCancellationTokenCancellation.
Returns
TryOpen(string, FileMode, FileAccess, int, out FileStream?)
Try opening file with given timeout.
public static bool TryOpen(string fileName, FileMode mode, FileAccess access, int timeoutMillis, out FileStream? stream)
Parameters
fileNamestringFile name.
modeFileModeMode to open file.
accessFileAccessDesired access.
timeoutMillisintTimeout in milliseconds.
streamFileStreamOpened stream.
Returns
- bool
True if file opened successfully in given timeout.
TryOpenRead(string, int, out FileStream?)
Try opening file for reading with given timeout.
public static bool TryOpenRead(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
fileNamestringFile name.
timeoutMillisintTimeout in milliseconds.
streamFileStreamOpened stream.
Returns
- bool
True if file opened successfully in given timeout.
TryOpenReadWrite(string, int, out FileStream?)
Try opening file for reading and writing with given timeout.
public static bool TryOpenReadWrite(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
fileNamestringFile name.
timeoutMillisintTimeout in milliseconds.
streamFileStreamOpened stream.
Returns
- bool
True if file opened successfully in given timeout.
TryOpenWrite(string, int, out FileStream?)
Try opening file for writing with given timeout.
public static bool TryOpenWrite(string fileName, int timeoutMillis, out FileStream? stream)
Parameters
fileNamestringFile name.
timeoutMillisintTimeout in milliseconds.
streamFileStreamOpened stream.
Returns
- bool
True if file opened successfully in given timeout.