Search Results for

    Show / Hide Table of Contents

    Class Directory

    Class for managing directories

    Inheritance
    object
    Directory
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: System.IO
    Assembly: System.IO.FileSystem.dll
    Syntax
    public static class Directory

    Methods

    CreateDirectory(string)

    Creates directory with the provided path.

    Declaration
    public static void CreateDirectory(string path)
    Parameters
    Type Name Description
    string path

    Path and name of the directory to create.

    Exceptions
    Type Condition
    IOException

    Path for creating the folder doesn't exist. This method does not create directories recursively.

    Delete(string, bool)

    Deletes directory from storage.

    Declaration
    public static void Delete(string path, bool recursive = false)
    Parameters
    Type Name Description
    string path

    Path to the directory to be removed.

    bool recursive

    Parameter to be implemented.

    Exceptions
    Type Condition
    IOException

    This method will throw DirectoryNotEmpty exception if folder is not empty.

    Exists(string)

    Determines whether the specified directory exists.

    Declaration
    public static bool Exists(string path)
    Parameters
    Type Name Description
    string path

    Path to the directory.

    Returns
    Type Description
    bool

    True if directory under given path exists, otherwise it returns false.

    Exceptions
    Type Condition
    ArgumentNullException

    Path must be defined.

    IOException

    Invalid drive or path to the parent folder doesn't exist.

    GetDirectories(string)

    List directories from the specified folder.

    Declaration
    public static string[] GetDirectories(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string[]

    When this method completes successfully, it returns an array of absolute paths to the subfolders in the specified directory.

    Exceptions
    Type Condition
    IOException

    Logical drive or a directory under given path does not exist.

    GetFiles(string)

    List files from the specified folder.

    Declaration
    public static string[] GetFiles(string path)
    Parameters
    Type Name Description
    string path

    Path to the directory to list files from.

    Returns
    Type Description
    string[]

    When this method completes successfully, it returns a array of paths of the files in the given folder.

    Exceptions
    Type Condition
    IOException

    Logical drive or a directory under given path does not exist.

    GetLastWriteTime(string)

    Determines the time of the last write/modification to directory under given path.

    Declaration
    public static DateTime GetLastWriteTime(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    DateTime

    Time of the last write/modification.

    Exceptions
    Type Condition
    IOException

    Logical drive or a directory under given path does not exist.

    GetLogicalDrives()

    Determines a list of available logical drives.

    Declaration
    public static string[] GetLogicalDrives()
    Returns
    Type Description
    string[]

    String[] of available drives, ex. "D:\"

    Move(string, string)

    Moves directory from specified path to a new location.

    Declaration
    public static void Move(string sourcePath, string destinationPath)
    Parameters
    Type Name Description
    string sourcePath

    Name of directory to move. Absolute path.

    string destinationPath

    New path and name for the directory.

    Exceptions
    Type Condition
    Exception

    Source directory not existing or destination folder already existing.

    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX