1. Script object OG.IO

    Article: AN0002173Updated:

    The object provides functions for work with files and folders.

    Script functions

    Name Description
    Work with files
    bool ExistsFile(string filePath) Function determines whether the file exists.
    void DeleteFile(string filePath) Method deletes the file.
    FileInfo GetFileInfo(string filePath) Function returns object FileInfo of the file.
    void AppendAllText(string path, string contents) Method adds to the file a text at the end.
    void AppendAllText(string path, string contents, Encoding encoding) Method adds to the file a text at the end according to the encoding defined.
    void FileCopy(string sourceFileName, string destFileName, bool overwrite) Method copies the file.
    void FileMove(string sourceFileName, string destFileName) Method moves the file.
    byte[] ReadAllBytes(string path) Function returns content of the file as a byte array.
    string[] ReadAllLines(string path) Function returns content of the file as a text array.
    string[] ReadAllLines(string path, Encoding encoding) Function returns content of the file as a text array according to the encoding defined.
    string ReadAllText(string path) Function returns content of the file as a text.
    string ReadAllText(string path, Encoding encoding) Function returns content of the file as a text according to the encoding defined.
    void WriteAllBytes(string path, byte[] bytes) Method writes a byte array into the file.
    void WriteAllLines(string path, string [] contents) Method writes a text array into the file.
    void WriteAllLines(string path, string [] contents, Encoding encoding) Method writes a text array according to the encoding defined into the file.
    void WriteAllText(string path, string contents) Method writes a text into the file.
    void WriteAllText(string path, string contents, Encoding encoding) Method writes a text according to the encoding defined into the file.
    Work with paths
    string GetExtension(string path) Function returns file extension according to the defined path.
    string GetFileName(string path) Function returns file name incl. file extension according to the defined path.
    string GetFileNameWithoutExtension(string path) Function returns file name excl. file extension according to the defined path.
    string GetRandomFileName() Function returns a random file name
    string GetTempFileName() Function creates a file name in the TEMP folder and returns path to it.
    string GetTempPath() Function returns path to the TEMP folder.
    bool HasExtension(string path) Function determines, whether there is file extension in the input path.
    string ChangeExtension(string path, string extension) Function changes the file extension.
    bool IsPathRooted(string path) Function determines, whether the path is full or relative.
    string Combine(string path, string path2) Function merges two parts of the path and adds/removes slashes between paths.
    string Combine(string path, string path2, string path3) Function merges three parts of the path and adds/removes slashes between paths.
    string Combine(string path, string path2, string path3, string path4) Function merges four parts of the path and adds/removes slashes between paths.
    string Combine(string path, string path2, string path3, string path4, string path5) Function merges five parts of the path and adds/removes slashes between paths.
    Work with folders
    void CreateDirectory(string path) Method creates a folder.
    string[] GetDirectories(string path) Function returns list of subfolders in the given path.
    string[] GetDirectories(string path, string searchPattern) Function returns list of subfolders in the given path with a possibility to filter names of the folders.
    string[] GetFiles(string path) Function returns list of files in the given path.
    string[] GetFiles(string path, string searchPattern) Function returns list of files in the given path with a possibility to filter names of the files.
    void DirectoryMove(string sourceDirName, string destDirName) Method moves a folder.
    bool DirectoryExists(string directoryPath) Function determines, whether the given folder exists.
    void DeleteDirectory(string directoryPath) Method deletes a folder.
    DirectoryInfo GetDirectoryInfo(string directoryPath) Function returns object DirectoryInfo of the folder.

     Object call

    OG.IO

×