Provides the base class for both FileInfo and DirectoryInfo objects.
For a list of all members of this type, see FileSystemInfo Members.
System.Object
System.MarshalByRefObject
System.IO.FileSystemInfo
System.IO.DirectoryInfo
System.IO.FileInfo
[Visual Basic] <Serializable> MustInherit Public Class FileSystemInfo Inherits MarshalByRefObject Implements ISerializable [C#] [Serializable] public abstract class FileSystemInfo : MarshalByRefObject, ISerializable [C++] [Serializable] public __gc __abstract class FileSystemInfo : public MarshalByRefObject, ISerializable [JScript] public Serializable abstract class FileSystemInfo extends MarshalByRefObject implements ISerializable
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
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.
When first called, FileSystemInfo calls Refresh and returns the cached information on APIs to get attributes and so on. On subsequent calls, you must call Refresh to get the latest copy of the information.
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:
The following table lists examples of other typical or related I/O tasks.
| To do this... | See the example in this topic... |
|---|---|
| Create a text file. | |
| Write to a text file. | |
| Read from a text file. | |
| Append text to a file. | |
| Delete a file. | File.Delete |
| Rename or move a file. | File.Move |
| Copy a file. | File.Copy |
| Create a directory. | Directory.CreateDirectory |
| Create a subdirectory. | CreateSubdirectory |
| Rename or move a directory. | Directory.Move |
| Delete a directory. | Directory.Delete |
| Copy a directory. | Directory |
| Sort files in a directory by size. | GetFileSystemInfos |
| See the files in a directory. | Name |
| See the subdirectories of a directory. | GetDirectories |
| See all the files in all subdirectories of a directory. | GetFileSystemInfos |
| Find the size of a directory. | Directory |
| Get the size of a file. | FileInfo.Length |
| Get the attributes of a file. | File.GetAttributes |
| Set the attributes of a file. | File.SetAttributes |
| Determine if a file exists. | File.Exists |
| Read from a binary file. | |
| Write to a binary file. | |
| Retrieve a file extension. | Path.GetExtension |
| Retrieve the fully qualified path of a file. | Path.GetFullPath |
| Retrieve the file name and extension from a path. | Path.GetFileName |
| Change the extension of a file. | Path.ChangeExtension |
Namespace: System.IO
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: Mscorlib (in Mscorlib.dll)
FileSystemInfo Members | System.IO Namespace |