Search Results for

    Show / Hide Table of Contents

    Class FileHelper

    Helper functions associated with file operations in .net core

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

    Fields

    LEMONEDGE_SIGNATURE_HASHES

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

    Declaration
    public static string[] LEMONEDGE_SIGNATURE_HASHES
    Field Value
    Type Description
    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
    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
    string fileName

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

    Returns
    Type Description
    byte[]

    The raw byte array of the specified file

    GetFileTextWriter(string, bool)

    Returns a TextWriter for the given fileName

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

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

    bool autoFlush

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

    Returns
    Type Description
    TextWriter

    A TextWriter for the given fileName

    GetRandomFileName()

    Returns a random valid file name

    Declaration
    public static string GetRandomFileName()
    Returns
    Type Description
    string

    A random valid file name

    GetSqlVarBinaryBytesFromString(string)

    When a file is stored directly in the database it is stored as the SQL varbinary type. When written to a CSV and imported into the system, the value is a string and needs to be converted to the bytes before writing to the database or storage location. An example of this is IDocumentAttachment.DocumentImage

    Declaration
    public static byte[] GetSqlVarBinaryBytesFromString(string rawString)
    Parameters
    Type Name Description
    string rawString

    The raw string value from the CSV

    Returns
    Type Description
    byte[]

    The actual bytes of the file data.

    GetTempDirectory()

    Returns a valid temp directory

    Declaration
    public static string GetTempDirectory()
    Returns
    Type Description
    string

    A valid temp directory

    GetTempFileName()

    Returns a valid temporary file name

    Declaration
    public static string GetTempFileName()
    Returns
    Type Description
    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
    string fileName

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

    Encoding encoding

    An optional encoding to use

    Returns
    Type Description
    string

    The entire text contents of the specified file

    OpenDirectory(DirectoryInfo)

    Declaration
    public static void OpenDirectory(DirectoryInfo directory)
    Parameters
    Type Name Description
    DirectoryInfo directory

    OpenFile(FileInfo, bool)

    Declaration
    public static void OpenFile(FileInfo file, bool select)
    Parameters
    Type Name Description
    FileInfo file
    bool select

    VerifyLemonEdgeSignedFile(FileInfo, bool)

    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
    FileInfo file

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

    bool throwError
    Returns
    Type Description
    bool

    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
    string fileName

    The full path name of the file to write data to

    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
    string contents

    The text to write to the file

    string fileName

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

    Encoding encoding

    An optional encoding to use

    In this article
    Back to top © LemonEdge Technologies. All rights reserved.