Export (0) Print
Expand All

FileSystemInfo Class

Provides the base class for both FileInfo and DirectoryInfo objects.

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

[<AbstractClass>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
[<FileIOPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)>]
type FileSystemInfo =  
    class
        inherit MarshalByRefObject
        interface ISerializable
    end

The FileSystemInfo type exposes the following members.

  NameDescription
Protected methodSupported by the XNA FrameworkFileSystemInfo()Initializes a new instance of the FileSystemInfo class.
Protected methodFileSystemInfo(SerializationInfo, StreamingContext)Initializes a new instance of the FileSystemInfo class with serialized data.
Top

  NameDescription
Public propertySupported by the XNA FrameworkAttributesGets or sets the attributes for the current file or directory.
Public propertySupported by the XNA FrameworkCreationTimeGets or sets the creation time of the current file or directory.
Public propertyCreationTimeUtcGets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.
Public propertySupported by the XNA FrameworkExistsGets a value indicating whether the file or directory exists.
Public propertySupported by the XNA FrameworkExtensionGets the string representing the extension part of the file.
Public propertySupported by the XNA FrameworkFullNameGets the full path of the directory or file.
Public propertySupported by the XNA FrameworkLastAccessTimeGets or sets the time the current file or directory was last accessed.
Public propertyLastAccessTimeUtcGets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.
Public propertySupported by the XNA FrameworkLastWriteTimeGets or sets the time when the current file or directory was last written to.
Public propertyLastWriteTimeUtcGets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.
Public propertySupported by the XNA FrameworkNameFor 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.
Top

  NameDescription
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkDeleteDeletes a file or directory.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetObjectDataSets the SerializationInfo object with the file name and additional exception information.
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodSupported by the XNA FrameworkMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkRefreshRefreshes the state of the object.
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected fieldSupported by the XNA FrameworkFullPathRepresents the fully qualified path of the directory or file.
Protected fieldSupported by the XNA FrameworkOriginalPathThe path originally specified by the user, whether relative or absolute.
Top

The FileSystemInfo class contains methods that are common to file and directory manipulation. A FileSystemInfo object can represent either a file or a directory, thus serving as the basis for FileInfo or DirectoryInfo objects. Use this base class when parsing a lot of files and directories.

A derived class can inherit from FileSystemInfo only if the derived class has the AllAccess permission from the FileIOPermissionAccess enumeration.

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.

For a list of common I/O tasks, see Common I/O Tasks.

The following example shows how to loop through all the files and directories, querying some information about each entry.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

Community Additions

ADD
Show:
© 2014 Microsoft