mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class FileHelper

    Provides utility methods for file-related operations.

    Inheritance
    object
    FileHelper
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: mk.helpers
    Assembly: mk.helpers.dll
    Syntax
    public static class FileHelper

    Methods

    DownloadFileAsync(string, Action<long>?, string)

    Asynchronously downloads a file from the specified URL and saves it to the specified file path.

    Declaration
    public static Task<DownloadFileResult> DownloadFileAsync(string url, Action<long>? onDownloadProgress, string filePath = null)
    Parameters
    Type Name Description
    string url

    The URL of the file to download.

    Action<long> onDownloadProgress

    An optional action to report download progress.

    string filePath

    The file path to save the downloaded file. If not provided, a temporary file will be used.

    Returns
    Type Description
    Task<DownloadFileResult>

    A task representing the asynchronous operation and containing information about the downloaded file.

    DownloadFileAsync(string, Action<DownloadProgress>?, string)

    Asynchronously downloads a file from the specified URL and saves it to the specified file path.

    Declaration
    public static Task<DownloadFileResult> DownloadFileAsync(string url, Action<FileHelper.DownloadProgress>? onDownloadProgress, string filePath = null)
    Parameters
    Type Name Description
    string url

    The URL of the file to download.

    Action<FileHelper.DownloadProgress> onDownloadProgress

    An optional action to report download progress.

    string filePath

    The file path to save the downloaded file. If not provided, a temporary file will be used.

    Returns
    Type Description
    Task<DownloadFileResult>

    A task representing the asynchronous operation and containing information about the downloaded file.

    ReadJsonArrayFile<T>(string, Action<T>, Action<double>, bool)

    Reads a JSON array file and processes its elements asynchronously.

    Declaration
    public static void ReadJsonArrayFile<T>(string filePath, Action<T> onData, Action<double> onProgress, bool readSynchronously = false)
    Parameters
    Type Name Description
    string filePath

    The path of the JSON array file to read.

    Action<T> onData

    An action to process each deserialized object.

    Action<double> onProgress

    An action to report progress while reading the file.

    bool readSynchronously

    Specifies whether to read synchronously or asynchronously.

    Type Parameters
    Name Description
    T

    The type of objects in the JSON array.

    In this article
    Back to top mk.helpers - MIT License