FileSystemInfo Class

Provides the base class for both FileInfo and DirectoryInfo objects.

Syntax

Declaration

[ComVisible(true)]
public abstract class FileSystemInfo : ISerializable

Inheritance Hierarchy

Inherited Members

System.Object

, , , , , ,

Constructors summary

Initializes a new instance of the FileSystemInfo class.

Fields summary

Represents the fully qualified path of the directory or file.

The path originally specified by the user, whether relative or absolute.

Properties summary

Gets or sets the attributes for the current file or directory.

Gets or sets the creation time of the current file or directory.

Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.

Gets a value indicating whether the file or directory exists.

Gets the string representing the extension part of the file.

Gets the full path of the directory or file.

Gets or sets the time the current file or directory was last accessed.

Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.

Gets or sets the time when the current file or directory was last written to.

Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.

For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a hierarchy exists. Otherwise, the Name property gets the name of the directory.

Methods summary

Deletes a file or directory.

Refreshes the state of the object.

Constructors

  • FileSystemInfo()

    Initializes a new instance of the FileSystemInfo class.

    [SecurityCritical]
    protected FileSystemInfo()

Fields

  • FullPath

    Represents the fully qualified path of the directory or file.

    protected string FullPath

    Exceptions

  • OriginalPath

    The path originally specified by the user, whether relative or absolute.

    protected string OriginalPath

Properties

  • Attributes

    Gets or sets the attributes for the current file or directory.

    public FileAttributes Attributes
    {
        get;
        [SecurityCritical]
        set;
    }

    Property Value

    Exceptions

  • CreationTime

    Gets or sets the creation time of the current file or directory.

    public DateTime CreationTime { get; set; }

    Property Value

    Exceptions

  • CreationTimeUtc

    Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.

    [ComVisible(false)]
    public DateTime CreationTimeUtc { get; set; }

    Property Value

    Exceptions

  • Exists

    Gets a value indicating whether the file or directory exists.

    public abstract bool Exists { get; }

    Property Value

    • true if the file or directory exists; otherwise, false.

  • Extension

    Gets the string representing the extension part of the file.

    public string Extension { get; }

    Property Value

  • FullName

    Gets the full path of the directory or file.

    public virtual string FullName { get; }

    Property Value

    • A string containing the full path.

    Exceptions

  • LastAccessTime

    Gets or sets the time the current file or directory was last accessed.

    public DateTime LastAccessTime { get; set; }

    Property Value

    • The time that the current file or directory was last accessed.

    Exceptions

  • LastAccessTimeUtc

    Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.

    [ComVisible(false)]
    public DateTime LastAccessTimeUtc { get; set; }

    Property Value

    • The UTC time that the current file or directory was last accessed.

    Exceptions

  • LastWriteTime

    Gets or sets the time when the current file or directory was last written to.

    public DateTime LastWriteTime { get; set; }

    Property Value

    • The time the current file was last written.

    Exceptions

  • LastWriteTimeUtc

    Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.

    [ComVisible(false)]
    public DateTime LastWriteTimeUtc { get; set; }

    Property Value

    • The UTC time when the current file was last written to.

    Exceptions

  • Name

    For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a hierarchy exists. Otherwise, the Name property gets the name of the directory.

    public abstract string Name { get; }

    Property Value

    • A string that is the name of the parent directory, the name of the last directory in the hierarchy, or the name of a file, including the file name extension.

Methods

  • Delete()

    Deletes a file or directory.

    public abstract void Delete()

    Exceptions

    • The specified path is invalid; for example, it is on an unmapped drive.

    • There is an open handle on the file or directory, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.

  • Refresh()

    Refreshes the state of the object.

    public void Refresh()

    Exceptions

    • A device such as a disk drive is not ready.

Details

Namespace

System.IO

Assembly

System.IO.FileSystem.dll

See Also