Class SafeFile
Safe version of C# 'File' class utilizing UniTask for async operations.
File operations with safety checks and utility methods.
Assembly: Glitch9.IO.dll
Syntax
public static class SafeFile
Methods
|
Edit this page
View Source
CheckMinSize(string, int)
Declaration
public static bool CheckMinSize(string fullPath, int minSizeByte = 1024)
Parameters
| Type |
Name |
Description |
| string |
fullPath |
|
| int |
minSizeByte |
|
Returns
|
Edit this page
View Source
Convert<T>(IFile[])
Declaration
public static List<T> Convert<T>(IFile[] list) where T : IFile
Parameters
| Type |
Name |
Description |
| IFile[] |
list |
|
Returns
Type Parameters
|
Edit this page
View Source
Delete(string)
Declaration
public static void Delete(string filePath)
Parameters
| Type |
Name |
Description |
| string |
filePath |
|
|
Edit this page
View Source
DeleteIfMinSizeNotMet(string, int)
Declaration
public static bool DeleteIfMinSizeNotMet(string fullPath, int minSizeByte = 1024)
Parameters
| Type |
Name |
Description |
| string |
fullPath |
|
| int |
minSizeByte |
|
Returns
|
Edit this page
View Source
Exists(string, bool)
Declaration
public static bool Exists(string filePath, bool log = false)
Parameters
Returns
|
Edit this page
View Source
Move(string, string, bool)
Declaration
public static string Move(string sourcePath, string destPath, bool overwrite = false)
Parameters
Returns
|
Edit this page
View Source
ReadAllBytes(string)
Declaration
public static byte[] ReadAllBytes(string filePath)
Parameters
| Type |
Name |
Description |
| string |
filePath |
|
Returns
|
Edit this page
View Source
ReadAllBytesAsync(string)
Declaration
public static UniTask<byte[]> ReadAllBytesAsync(string filePath)
Parameters
| Type |
Name |
Description |
| string |
filePath |
|
Returns
| Type |
Description |
| UniTask<byte[]> |
|
|
Edit this page
View Source
ReadAllTextSharedAccessAsync(string, CancellationToken)
Declaration
public static UniTask<string> ReadAllTextSharedAccessAsync(string path, CancellationToken ct)
Parameters
Returns
| Type |
Description |
| UniTask<string> |
|
|
Edit this page
View Source
ReplaceFile(string, string)
Declaration
public static void ReplaceFile(string tmp, string finalPath)
Parameters
|
Edit this page
View Source
TryDelete(string)
Declaration
public static void TryDelete(string filePath)
Parameters
| Type |
Name |
Description |
| string |
filePath |
|
|
Edit this page
View Source
TryMoveWithRetryAsync(string, string, bool, CancellationToken)
Declaration
public static UniTask<string> TryMoveWithRetryAsync(string src, string dst, bool overwrite, CancellationToken cancellationToken)
Parameters
Returns
| Type |
Description |
| UniTask<string> |
|
|
Edit this page
View Source
ValidateFileAtPath(string)
Declaration
public static void ValidateFileAtPath(string filePath)
Parameters
| Type |
Name |
Description |
| string |
filePath |
|
|
Edit this page
View Source
WriteAllBytesAsync(string, byte[])
Declaration
public static UniTask WriteAllBytesAsync(string fullPath, byte[] data)
Parameters
Returns
|
Edit this page
View Source
WriteAtomicAsync(string, string, CancellationToken)
Atomically writes a temp file and then moves it to the target file as a single operation.
Ensures the file is either fully written or not written at all, even in case of interruption.
Declaration
public static UniTask WriteAtomicAsync(string path, string content, CancellationToken ct)
Parameters
Returns
|
Edit this page
View Source
WriteFileAsync(string, string)
Declaration
public static UniTask WriteFileAsync(string fullPath, string content)
Parameters
Returns