Search Results for

    Show / Hide Table of Contents

    Class SafeFile

    Safe version of C# 'File' class utilizing UniTask for async operations. File operations with safety checks and utility methods.

    Inheritance
    object
    SafeFile
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9.IO.Files
    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
    Type Description
    bool
    | 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 Description
    List<T>
    Type Parameters
    Name Description
    T
    | 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
    Type Description
    bool
    | Edit this page View Source

    Exists(string, bool)

    Declaration
    public static bool Exists(string filePath, bool log = false)
    Parameters
    Type Name Description
    string filePath
    bool log
    Returns
    Type Description
    bool
    | Edit this page View Source

    Move(string, string, bool)

    Declaration
    public static string Move(string sourcePath, string destPath, bool overwrite = false)
    Parameters
    Type Name Description
    string sourcePath
    string destPath
    bool overwrite
    Returns
    Type Description
    string
    | Edit this page View Source

    ReadAllBytes(string)

    Declaration
    public static byte[] ReadAllBytes(string filePath)
    Parameters
    Type Name Description
    string filePath
    Returns
    Type Description
    byte[]
    | 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
    Type Name Description
    string path
    CancellationToken ct
    Returns
    Type Description
    UniTask<string>
    | Edit this page View Source

    ReplaceFile(string, string)

    Declaration
    public static void ReplaceFile(string tmp, string finalPath)
    Parameters
    Type Name Description
    string tmp
    string finalPath
    | 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
    Type Name Description
    string src
    string dst
    bool overwrite
    CancellationToken cancellationToken
    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
    Type Name Description
    string fullPath
    byte[] data
    Returns
    Type Description
    UniTask
    | 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
    Type Name Description
    string path
    string content
    CancellationToken ct
    Returns
    Type Description
    UniTask
    | Edit this page View Source

    WriteFileAsync(string, string)

    Declaration
    public static UniTask WriteFileAsync(string fullPath, string content)
    Parameters
    Type Name Description
    string fullPath
    string content
    Returns
    Type Description
    UniTask
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation