Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​IO.​FileSystemInfo

Assembly: System.Runtime

Inheritance: object → MarshalByRefObject → FileSystemInfo

Provides the base class for both <see cref="T:System.IO.FileInfo" /> and <see cref="T:System.IO.DirectoryInfo" /> objects.

Fields and Constants

protected string
FullPath
Represents the fully qualified path of the directory or file.
protected string
OriginalPath
The path originally specified by the user, whether relative or absolute.

Properties

Attributes
Gets or sets the attributes for the current file or directory.
public DateTime
CreationTime
Gets or sets the creation time of the current file or directory.
public DateTime
CreationTimeUtc
Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.
public bool
Exists
Gets a value indicating whether the file or directory exists.
public string
Extension
Gets the extension part of the file name, including the leading dot <c>.</c> even if it is the entire file name, or an empty string if no extension is present.
public string
FullName
Gets the full path of the directory or file.
public DateTime
LastAccessTime
Gets or sets the time the current file or directory was last accessed.
public DateTime
LastAccessTimeUtc
Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.
public DateTime
LastWriteTime
Gets or sets the time when the current file or directory was last written to.
public DateTime
LastWriteTimeUtc
Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.
public string
LinkTarget
Gets the target path of the link located in <see cref="P:System.IO.FileSystemInfo.FullName" /> , or <see langword="null" /> if this <see cref="T:System.IO.FileSystemInfo" /> instance doesn't represent a link.
public string
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 <see langword="Name" /> property gets the name of the directory.
public UnixFileMode
UnixFileMode
Gets or sets the Unix file mode for the current file or directory.

Methods

public void
CreateAsSymbolicLink​(string pathToTarget)
pathToTarget The path of the symbolic link target.
Creates a symbolic link located in <see cref="P:System.IO.FileSystemInfo.FullName" /> that points to the specified <paramref name="pathToTarget" /> .
public void
Delete​()
Deletes a file or directory.
public void
GetObjectData​(Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext context)
info The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.
context The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.
Sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the file name and additional exception information.
public void
Refresh​()
Refreshes the state of the object.
ResolveLinkTarget​(bool returnFinalTarget)
returnFinalTarget <see langword="true" /> to follow links to the final target; <see langword="false" /> to return the immediate next link.
Returns A <see cref="T:System.IO.FileSystemInfo" /> instance if the link exists, independently if the target exists or not; <see langword="null" /> if this file or directory is not a link.
Gets the target of the specified link.
public string
ToString​()
Returns A string with the original path.
Returns the original path. Use the <see cref="P:System.IO.FileSystemInfo.FullName" /> or <see cref="P:System.IO.FileSystemInfo.Name" /> properties for the full path or file/directory name.
public object
GetLifetimeService​()
Inherited from MarshalByRefObject
Returns An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease" /> used to control the lifetime policy for this instance.
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
public object
InitializeLifetimeService​()
Inherited from MarshalByRefObject
Returns An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease" /> used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the <see cref="P:System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime" /> property.
Obtains a lifetime service object to control the lifetime policy for this instance.
protected MarshalByRefObject
MemberwiseClone​(bool cloneIdentity)
Inherited from MarshalByRefObject
cloneIdentity <see langword="false" /> to delete the current <see cref="T:System.MarshalByRefObject" /> object's identity, which will cause the object to be assigned a new identity when it is marshaled across a remoting boundary. A value of <see langword="false" /> is usually appropriate. <see langword="true" /> to copy the current <see cref="T:System.MarshalByRefObject" /> object's identity to its clone, which will cause remoting client calls to be routed to the remote server object.
Returns A shallow copy of the current <see cref="T:System.MarshalByRefObject" /> object.
Creates a shallow copy of the current <see cref="T:System.MarshalByRefObject" /> object.
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .