Click or drag to resize

FileInfo Class

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.
Inheritance Hierarchy

Namespace:  Alphaleonis.Win32.Filesystem
Assembly:  AlphaFS (in AlphaFS.dll) Version: 2.2
Syntax
[SerializableAttribute]
public sealed class FileInfo : FileSystemInfo

The FileInfo type exposes the following members.

Constructors
  NameDescription
Public methodFileInfo(String)
Initializes a new instance of the FileInfo class, which acts as a wrapper for a file path.
Public methodFileInfo(String, PathFormat)
[AlphaFS] Initializes a new instance of the FileInfo class, which acts as a wrapper for a file path.
Public methodFileInfo(KernelTransaction, String)
[AlphaFS] Initializes a new instance of the FileInfo class, which acts as a wrapper for a file path.
Public methodFileInfo(KernelTransaction, String, PathFormat)
[AlphaFS] Initializes a new instance of the FileInfo class, which acts as a wrapper for a file path.
Top
Properties
  NameDescription
Public propertyAttributes
Gets or sets the attributes for the current file or directory.
(Inherited from FileSystemInfo.)
Public propertyCreationTime
Gets or sets the creation time of the current file or directory.
(Inherited from FileSystemInfo.)
Public propertyCreationTimeUtc
Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.
(Inherited from FileSystemInfo.)
Public propertyDirectory
Gets an instance of the parent directory.
Public propertyDirectoryName
Gets a string representing the directory's full path.
Protected propertyDisplayPath
Returns the path as a string.
(Inherited from FileSystemInfo.)
Public propertyEntryInfo
[AlphaFS] Gets the instance of the FileSystemEntryInfo class.
(Inherited from FileSystemInfo.)
Public propertyExists
Gets a value indicating whether the file exists.
(Overrides FileSystemInfoExists.)
Public propertyExtension
Gets the string representing the extension part of the file.
(Inherited from FileSystemInfo.)
Public propertyFullName
Gets the full path of the directory or file.
(Inherited from FileSystemInfo.)
Protected propertyIsDirectory
[AlphaFS] The initial "IsDirectory" indicator that was passed to the constructor.
(Inherited from FileSystemInfo.)
Public propertyIsReadOnly
Gets or sets a value that determines if the current file is read only.
Public propertyLastAccessTime
Gets or sets the time the current file or directory was last accessed.
(Inherited from FileSystemInfo.)
Public propertyLastAccessTimeUtc
Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.
(Inherited from FileSystemInfo.)
Public propertyLastWriteTime
Gets or sets the time when the current file or directory was last written to.
(Inherited from FileSystemInfo.)
Public propertyLastWriteTimeUtc
Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.
(Inherited from FileSystemInfo.)
Public propertyLength
Gets the size, in bytes, of the current file.
Protected propertyLongFullName
The full path of the file system object in Unicode (LongPath) format.
(Inherited from FileSystemInfo.)
Public propertyName
Gets the name of the file.
(Overrides FileSystemInfoName.)
Protected propertyTransaction
[AlphaFS] Represents the KernelTransaction that was passed to the constructor.
(Inherited from FileSystemInfo.)
Top
Methods
  NameDescription
Public methodAppendText
Creates a StreamWriter that appends text to the file represented by this instance of the FileInfo.
Public methodAppendText(Encoding)
Creates a StreamWriter that appends text to the file represented by this instance of the FileInfo.
Public methodCompress
[AlphaFS] Compresses a file using NTFS compression.
Public methodCopyTo(String)
Copies an existing file to a new file, disallowing the overwriting of an existing file.

Return Value

Type: 
A new FileInfo instance with a fully qualified path.
Remarks

Use this method to prevent overwriting of an existing file by default.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.
Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, PathFormat)
[AlphaFS] Copies an existing file to a new file, disallowing the overwriting of an existing file.
Remarks

Use this method to prevent overwriting of an existing file by default.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, Boolean)
Copies an existing file to a new file, allowing the overwriting of an existing file.
Remarks

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, PathFormat)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.
Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, Boolean)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.
Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, Boolean, PathFormat)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file.
Remarks

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, CopyMoveProgressRoutine, Object)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.

and the possibility of notifying the application of its progress through a callback function.

Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, Boolean, PathFormat)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.
Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, CopyMoveProgressRoutine, Object, PathFormat)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.
Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, Boolean, CopyMoveProgressRoutine, Object)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.

and the possibility of notifying the application of its progress through a callback function.

Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCopyTo(String, CopyOptions, Boolean, CopyMoveProgressRoutine, Object, PathFormat)
[AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, CopyOptions can be specified.

and the possibility of notifying the application of its progress through a callback function.

Remarks

Option NoBuffering is recommended for very large file transfers.

Use this method to allow or prevent overwriting of an existing file.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodCreate
Creates a file.
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodCreateText
Creates a instance that writes a new text file.
Public methodDecompress
[AlphaFS] Decompresses an NTFS compressed file.
Public methodDecrypt
Decrypts a file that was encrypted by the current account using the Encrypt method.
Public methodDelete
Permanently deletes a file.
(Overrides FileSystemInfoDelete.)
Public methodDelete(Boolean)
[AlphaFS] Permanently deletes a file.
Public methodEncrypt
Encrypts a file so that only the account used to encrypt the file can decrypt it.
Public methodEnumerateAlternateDataStreams
[AlphaFS] Returns an enumerable collection of AlternateDataStreamInfo instances for the file.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from FileSystemInfo.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAccessControl
Gets a FileSecurity object that encapsulates the access control list (ACL) entries for the file described by the current FileInfo object.
Public methodGetAccessControl(AccessControlSections)
Gets a FileSecurity object that encapsulates the specified type of access control list (ACL) entries for the file described by the current FileInfo object.
Public methodGetFileId
[AlphaFS] Gets the unique identifier for the file. The identifier is composed of a 64-bit volume serial number and 128-bit file system entry identifier.
Public methodGetHash
[AlphaFS] Calculates the hash/checksum.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from FileSystemInfo.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodIsLocked
[AlphaFS] Compresses a file using NTFS compression.
Protected methodMemberwiseClone
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 methodMoveTo(String)
Moves a specified file to a new location, providing the option to specify a new file name.
Remarks

Use this method to prevent overwriting of an existing file by default.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodMoveTo(String, MoveOptions)
[AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, MoveOptions can be specified.

Return Value

Type: 

Returns a new FileInfo instance with a fully qualified path when successfully moved,

Remarks

Use this method to allow or prevent overwriting of an existing file.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodMoveTo(String, PathFormat)
[AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name.

Return Value

Type: 

Returns a new FileInfo instance with a fully qualified path when successfully moved,

Remarks

Use this method to prevent overwriting of an existing file by default.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodMoveTo(String, MoveOptions, PathFormat)
[AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, MoveOptions can be specified.

Return Value

Type: 

Returns a new FileInfo instance with a fully qualified path when successfully moved,

Remarks

Use this method to allow or prevent overwriting of an existing file.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodMoveTo(String, MoveOptions, CopyMoveProgressRoutine, Object)
[AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, MoveOptions can be specified,

and the possibility of notifying the application of its progress through a callback function.

Remarks

Use this method to allow or prevent overwriting of an existing file.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodMoveTo(String, MoveOptions, CopyMoveProgressRoutine, Object, PathFormat)
[AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, MoveOptions can be specified.
Remarks

Use this method to allow or prevent overwriting of an existing file.

This method works across disk volumes.

For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.

If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.

Public methodOpen(FileMode)
Opens a file in the specified mode.
Public methodOpen(FileMode, FileAccess)
Opens a file in the specified mode with read, write, or read/write access.
Public methodOpen(FileMode, FileSystemRights)
[AlphaFS] Opens a file in the specified mode with read, write, or read/write access.
Public methodOpen(FileMode, FileAccess, FileShare)
Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
Public methodOpen(FileMode, FileSystemRights, FileShare)
[AlphaFS] Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
Public methodOpenRead
Creates a read-only FileStream.
Public methodOpenText
Creates a StreamReader with NativeMethods.DefaultFileEncoding encoding that reads from an existing text file.
Public methodOpenText(Encoding)
[AlphaFS] Creates a StreamReader with Encoding that reads from an existing text file.
Public methodOpenWrite
Creates a write-only FileStream.
Public methodRefresh
Refreshes the state of the object.
(Inherited from FileSystemInfo.)
Public methodRefreshEntryInfo
Refreshes the state of the FileSystemEntryInfo EntryInfo instance.
Public methodReplace(String, String)
Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file.
Public methodReplace(String, String, PathFormat)
[AlphaFS] Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
Public methodReplace(String, String, Boolean)
Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
Public methodReplace(String, String, Boolean, PathFormat)
[AlphaFS] Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
Public methodSetAccessControl(FileSecurity)
Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileInfo object.
Public methodSetAccessControl(FileSecurity, AccessControlSections)
Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileInfo object.
Public methodToString
Returns the path as a string.
(Overrides FileSystemInfoToString.)
Top
Fields
  NameDescription
Protected fieldFullPath
Represents the fully qualified path of the file or directory.
(Inherited from FileSystemInfo.)
Protected fieldOriginalPath
The path originally specified by the user, whether relative or absolute.
(Inherited from FileSystemInfo.)
Top
See Also