mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 4.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.IO.FileSystemInfo System.Runtime.InteropServices.ComVisible(true)

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

If you are performing multiple operations on the same file, it can be more efficient to use instance methods instead of the corresponding static methods of the class, because a security check will not always be necessary.

Many of the methods return other I/O types when you create or open files. You can use these other types to further manipulate a file. For more information, see specific members such as , , , , or .

By default, full read/write access to new files is granted to all users.

The following table describes the enumerations that are used to customize the behavior of various methods.

Enumeration

Description

Specifies read and write access to a file.

Specifies the level of access permitted for a file that is already in use.

Specifies whether the contents of an existing file are preserved or overwritten, and whether requests to create an existing file cause an exception.

In members that accept a path as an input string, that path must be well-formed or an exception is raised. For example, if a path is fully qualified but begins with a space, the path is not trimmed in methods of the class. Therefore, the path is malformed and an exception is raised. Similarly, a path or a combination of paths cannot be fully qualified twice. For example, "c:\temp c:\windows" also raises an exception in most cases. Ensure that your paths are well-formed when using methods that accept a path string.

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.

The class provides the following properties that enable you to retrieve information about a file. For an example of how to use each property, see the property pages.

The property retrieves an object that represents the parent directory of a file.

The property retrieves the full path of the parent directory of a file.

The property checks for the presence of a file before operating on it.

The property retrieves or sets a value that specifies whether a file can be modified.

The retrieves the size of a file.

The retrieves the name of a file.

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

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  You can specify either the fully qualified or the relative file name, but the security check gets the fully qualified name.

  Initializes a new instance of the class, which acts as a wrapper for a file path.

  The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.StreamWriter To be added

  Creates a that appends text to the file represented by this instance of the .

  A new StreamWriter.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileInfo ``

  Use the method to allow 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

  Copies an existing file to a new file, disallowing the overwriting of an existing file.

  A new file with a fully qualified path.

  The name of the new file to copy to.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileInfo `` ``

  Use this method to allow or prevent overwriting of an existing file. Use the 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

  Copies an existing file to a new file, allowing the overwriting of an existing file.

  A new file, or an overwrite of an existing file if is true. If the file exists and is false, an is thrown.

  The name of the new file to copy to. true to allow an existing file to be overwritten; otherwise, false.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream

  By default, full read/write access to new files is granted to all users.

  This method is a wrapper for the functionality provided by .

  Creates a file.

  A new file.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.StreamWriter

  By default, full read/write access to new files is granted to all users.

  Creates a that writes a new text file.

  A new StreamWriter.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void

  The method allows you to decrypt a file that was encrypted using the method. The method can decrypt only files that were encrypted using the current user account.

  Both the method and the method use the cryptographic service provider (CSP) installed on the computer and the file encryption keys of the process calling the method.

  The current file system must be formatted as NTFS and the current operating system must be Microsoft Windows NT or later.

  Decrypts a file that was encrypted by the current account using the method.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  If the file does not exist, this method does nothing.

  Permanently deletes a file.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.DirectoryInfo To be added: an object of type 'DirectoryInfo'

  To get the parent directory as a string, use the property.

  Gets an instance of the parent directory.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added: an object of type 'string'

  To get the parent directory as a object, use the property.

  When first called, calls and caches information about the file. On subsequent calls, you must call to get the latest copy of the information.

  Gets a string representing the directory's full path.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void

  The method allows you to encrypt a file so that only the account used to call this method can decrypt it. Use the method to decrypt a file encrypted by the method.

  Both the method and the method use the cryptographic service provider (CSP) installed on the computer and the file encryption keys of the process calling the method.

  The current file system must be formatted as NTFS and the current operating system must be Microsoft Windows NT or later.

  Encrypts a file so that only the account used to encrypt the file can decrypt it.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added.

  When first called, calls and caches information about the file. On subsequent calls, you must call to get the latest copy of the information.

  The property returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, a failing or missing disk, or if the caller does not have permission to read the file.

  Gets a value indicating whether a file exists.

- Method
  2.0.0.0
  4.0.0.0
  System.Security.AccessControl.FileSecurity

  Use the method to retrieve the access control list (ACL) entries for the current file.

  An ACL describes individuals and/or groups who have, or do not have, rights to specific actions on the given file. For more information, see ACL Technology Overview and How to: Add or Remove an Access Control List Entry.

  Gets a object that encapsulates the access control list (ACL) entries for the file described by the current object.

  A object that encapsulates the access control rules for the current file.

- Method
  2.0.0.0
  4.0.0.0
  System.Security.AccessControl.FileSecurity ``

  Use the method to retrieve the access control list (ACL) entries for the current file.

  An ACL describes individuals and/or groups who have, or do not have, rights to specific actions on the given file. For more information, see ACL Technology Overview and How to: Add or Remove an Access Control List Entry.

  Gets a object that encapsulates the specified type of access control list (ACL) entries for the file described by the current object.

  A object that encapsulates the access control rules for the current file.

  One of the values that specifies which group of access control entries to retrieve.
- Property
  2.0.0.0
  4.0.0.0
  System.Boolean To be added.

  Use the property to quickly determine or change whether the current file is read only.

  When first called, calls and caches information about the file. On subsequent calls, you must call to get the latest copy of the information.

  Gets or sets a value that determines if the current file is read only.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 To be added: an object of type 'long'

  The value of the property is pre-cached if the current instance of the object was returned from any of the following methods:

  To get the latest value, call the method.

  Gets the size, in bytes, of the current file.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  This method works across disk volumes. For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt.

  Moves a specified file to a new location, providing the option to specify a new file name.

  The path to move the file to, which can specify a different file name.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added.

  When first called, calls and caches information about the file. On subsequent calls, you must call to get the latest copy of the information.

  The name of the file includes the file extension.

  Gets the name of the file.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream `` To be added

  Opens a file in the specified mode.

  A file opened in the specified mode, with read/write access and unshared.

  A constant specifying the mode (for example, Open or Append) in which to open the file.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream `` `` To be added

  Opens a file in the specified mode with read, write, or read/write access.

  A object opened in the specified mode and access, and unshared.

  A constant specifying the mode (for example, Open or Append) in which to open the file. A constant specifying whether to open the file with Read, Write, or ReadWrite file access.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream `` `` `` To be added

  Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.

  A object opened with the specified mode, access, and sharing options.

  A constant specifying the mode (for example, Open or Append) in which to open the file. A constant specifying whether to open the file with Read, Write, or ReadWrite file access. A constant specifying the type of access other FileStream objects have to this file.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream

  This method returns a read-only object with the mode set to .

  Creates a read-only .

  A new read-only object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.StreamReader To be added

  Creates a with UTF8 encoding that reads from an existing text file.

  A new StreamReader with UTF8 encoding.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileStream

  The method opens a file if one already exists for the file path, or creates a new file if one does not exist. For an existing file, it does not append the new text to the existing text. Instead, it overwrites the existing characters with the new characters. If you overwrite a longer string (such as "This is a test of the OpenWrite method") with a shorter string (like "Second run"), the file will contain a mix of the strings ("Second runtest of the OpenWrite method").

  Creates a write-only .

  A write-only unshared object for a new or existing file.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.IO.FileInfo `` ``

  The method replaces the contents of a specified file with the contents of the file described by the current object. It also creates a backup of the file that was replaced. Finally, it returns a new object that describes the overwritten file.

  This method will succeed in Windows 2000 environments if the is read-only and will not raise an exception. Use the property to check if the destination file is read-only before attempting to replace it.

  Pass null to the parameter if you do not want to create a backup of the file being replaced.

  Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file.

  A object that encapsulates information about the file described by the parameter.

  The name of a file to replace with the current file. The name of a file with which to create a backup of the file described by the parameter.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.IO.FileInfo `` `` ``

  The method replaces the contents of a specified file with the contents of the file described by the current object. It also creates a backup of the file that was replaced. Finally, it returns a new object that describes the overwritten file.

  This method will succeed in Windows 2000 environments if the is read-only and will not raise an exception. Use the property to check if the destination file is read-only before attempting to replace it.

  Pass null to the parameter if you do not want to create a backup of the file being replaced.

  Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.

  A object that encapsulates information about the file described by the parameter.

  The name of a file to replace with the current file. The name of a file with which to create a backup of the file described by the parameter. true to ignore merge errors (such as attributes and ACLs) from the replaced file to the replacement file; otherwise false.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method applies access control list (ACL) entries to the current file that represents the noninherited ACL list.

  Use the method whenever you need to add or remove ACL entries from a file.

  The ACL specified for the parameter replaces the existing ACL for the file. To add permissions for a new user, use the method to obtain the existing ACL, modify it, and then use to apply it back to the file.

  An ACL describes individuals and/or groups who have, or do not have, rights to specific actions on the given file. For more information, see ACL Technology Overview and How to: Add or Remove an Access Control List Entry.

  The method persists only objects that have been modified after object creation. If a object has not been modified, it will not be persisted to a file. Therefore, it is not possible to retrieve a object from one file and reapply the same object to another file.

  To copy ACL information from one file to another:

  Use the method to retrieve the object from the source file.

  Create a new object for the destination file.

  Use the or method of the source object to retrieve the ACL information.

  Use the or method to copy the information retrieved in step 3 to the destination object.

  Set the destination object to the destination file using the method.

  Applies access control list (ACL) entries described by a object to the file described by the current object.

  A object that describes an access control list (ACL) entry to apply to the current file.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The string returned by the method represents path that was passed to the constructor. When you create a object using the constructors, the method returns the fully qualified path. However, there are cases where the string returned by the method does not represent the fully qualified path. For example, when you create a object using the method, the method does not represent the fully qualified path.

  Returns the path as a string.

  A string representing the path.