Search Results for

    Show / Hide Table of Contents

    Class FileHelper

    Helper functions associated with file operations in .net core

    Inheritance
    System.Object
    FileHelper
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: LemonEdge.Utils
    Assembly: Utils.dll
    Syntax
    public static class FileHelper

    Fields

    LEMONEDGE_SIGNATURE_HASH

    The signature of any library signed by LemonEdge. Used for verifying libraries.

    Declaration
    public const string LEMONEDGE_SIGNATURE_HASH = "7E778F27328B33C7B29E990277F4FAE522FBDB61"
    Field Value
    Type Description
    System.String

    Methods

    EnsurePathExists(String)

    Given a specified full file path, this ensures the path exists by creating the folders in the path as required

    Declaration
    public static void EnsurePathExists(string filePathOrDirectory)
    Parameters
    Type Name Description
    System.String filePathOrDirectory

    The full path to a fil or directory

    GetFileData(String)

    Returns the byte array data of the specified fulle path fileName

    Declaration
    public static byte[] GetFileData(string fileName)
    Parameters
    Type Name Description
    System.String fileName

    The full path to a file to return the byte data of

    Returns
    Type Description
    System.Byte[]

    The raw byte array of the specified file

    GetFileTextWriter(String, Boolean)

    Returns a System.IO.TextWriter for the given fileName

    Declaration
    public static TextWriter GetFileTextWriter(string fileName, bool autoFlush)
    Parameters
    Type Name Description
    System.String fileName

    The full path to a file to create a text writer for

    System.Boolean autoFlush

    Indicates if the writer should auto flush changes to the underlying file

    Returns
    Type Description
    System.IO.TextWriter

    A System.IO.TextWriter for the given fileName

    GetRandomFileName()

    Returns a random valid file name

    Declaration
    public static string GetRandomFileName()
    Returns
    Type Description
    System.String

    A random valid file name

    GetTempDirectory()

    Returns a valid temp directory

    Declaration
    public static string GetTempDirectory()
    Returns
    Type Description
    System.String

    A valid temp directory

    GetTempFileName()

    Returns a valid temporary file name

    Declaration
    public static string GetTempFileName()
    Returns
    Type Description
    System.String

    A valid temporary file name

    GetTextFromFile(String, Encoding)

    Return the entire text content of the specified full path fileName using an optional encoding

    Declaration
    public static string GetTextFromFile(string fileName, Encoding encoding = null)
    Parameters
    Type Name Description
    System.String fileName

    The full path of the file to return the text contents of

    System.Text.Encoding encoding

    An optional encoding to use

    Returns
    Type Description
    System.String

    The entire text contents of the specified file

    VerifyLemonEdgeSignedFile(FileInfo, Boolean)

    Verifies that the provided file has been signed by a certificate owned by LemonEdge

    Declaration
    public static bool VerifyLemonEdgeSignedFile(this FileInfo file, bool throwError = false)
    Parameters
    Type Name Description
    System.IO.FileInfo file

    The file to verify if it has been signed by a LemonEdge certificate

    System.Boolean throwError
    Returns
    Type Description
    System.Boolean

    True if the file has been signed by a LemonEdge certificate

    WriteFileData(String, Byte[])

    Writes the specified byte array data to the specified full path fileName

    Declaration
    public static void WriteFileData(string fileName, byte[] data)
    Parameters
    Type Name Description
    System.String fileName

    The full path name of the file to write data to

    System.Byte[] data

    The data to be writeen to the file

    WriteTextToFile(String, String, Encoding)

    Writes the specified contents text to the specified full path fileName using an optional encoding

    Declaration
    public static void WriteTextToFile(string contents, string fileName, Encoding encoding = null)
    Parameters
    Type Name Description
    System.String contents

    The text to write to the file

    System.String fileName

    The full path to the file to write the specified text to

    System.Text.Encoding encoding

    An optional encoding to use

    In This Article
    Back to top © LemonTree Software Ltd. All rights reserved.