FileInfo Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects. This class cannot be inherited.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

[<Sealed>]
[<SerializableAttribute>]
type FileInfo =  
    class
        inherit FileSystemInfo
    end

The FileInfo type exposes the following members.

  NameDescription
Public methodFileInfoInitializes a new instance of the FileInfo class, which acts as a wrapper for a file path.
Top

  NameDescription
Public propertyAttributesGets or sets the attributes for the current file or directory. (Inherited from FileSystemInfo.)
Public propertyCreationTimeGets or sets the creation time of the current file or directory. (Inherited from FileSystemInfo.)
Public propertyCreationTimeUtcGets or sets the creation time, in coordinated universal time (UTC), of the current file or directory. (Inherited from FileSystemInfo.)
Public propertyDirectoryGets an instance of the parent directory.
Public propertyDirectoryNameGets a string representing the directory's full path.
Public propertyExistsGets a value indicating whether a file exists. (Overrides FileSystemInfo..::..Exists.)
Public propertyExtensionGets the string representing the extension part of the file. (Inherited from FileSystemInfo.)
Public propertyFullNameGets the full path of the directory or file. (Inherited from FileSystemInfo.)
Public propertyLastAccessTimeGets or sets the time the current file or directory was last accessed. (Inherited from FileSystemInfo.)
Public propertyLastAccessTimeUtcGets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. (Inherited from FileSystemInfo.)
Public propertyLastWriteTimeGets or sets the time when the current file or directory was last written to. (Inherited from FileSystemInfo.)
Public propertyLastWriteTimeUtcGets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. (Inherited from FileSystemInfo.)
Public propertyLengthGets the size, in bytes, of the current file.
Public propertyNameGets the name of the file. (Overrides FileSystemInfo..::..Name.)
Top

  NameDescription
Public methodCreateCreates a file.
Public methodDeletePermanently deletes a file. (Overrides FileSystemInfo..::..Delete()()()().)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodRefreshRefreshes the state of the object. (Inherited from FileSystemInfo.)
Public methodToStringReturns the path as a string. (Overrides Object..::..ToString()()()().)
Top

Use the FileInfo class for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files.

If you are going to reuse an object several times, consider using the instance method of FileInfo instead of the corresponding static methods of the File class, because a security check will not always be necessary.

In members that accept a path, the path can refer to a file or just a directory. The specified path can also refer to a relative path or a Universal Naming Convention (UNC) path for a server and share name. For example, all the following are acceptable paths:

  • "c:\\MyDir\\MyFile.txt" in C#, or "c:\MyDir\MyFile.txt" in Visual Basic.

  • "c:\\MyDir" in C#, or "c:\MyDir" in Visual Basic.

  • "MyDir\\MySubdir" in C#, or "MyDir\MySubDir" in Visual Basic.

  • "\\\\MyServer\\MyShare" in C#, or "\\MyServer\MyShare" in Visual Basic.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: