Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign updotnet-api-docs/xml/System.IO/FileInfo.xml
Go to file| <Type Name="FileInfo" FullName="System.IO.FileInfo"> | |
| <TypeSignature Language="C#" Value="public sealed class FileInfo : System.IO.FileSystemInfo" /> | |
| <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit FileInfo extends System.IO.FileSystemInfo" FrameworkAlternate="dotnet-uwp-10.0;net-5.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" /> | |
| <TypeSignature Language="DocId" Value="T:System.IO.FileInfo" /> | |
| <TypeSignature Language="VB.NET" Value="Public NotInheritable Class FileInfo
Inherits FileSystemInfo" /> | |
| <TypeSignature Language="C++ CLI" Value="public ref class FileInfo sealed : System::IO::FileSystemInfo" /> | |
| <TypeSignature Language="F#" Value="type FileInfo = class
 inherit FileSystemInfo" /> | |
| <TypeSignature Language="ILAsm" Value=".class public auto ansi serializable sealed beforefieldinit FileInfo extends System.IO.FileSystemInfo" FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" /> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <TypeForwardingChain> | |
| <TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.FileSystem" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" /> | |
| </TypeForwardingChain> | |
| <Base> | |
| <BaseTypeName>System.IO.FileSystemInfo</BaseTypeName> | |
| </Base> | |
| <Interfaces /> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName> | |
| </Attribute> | |
| <Attribute FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0"> | |
| <AttributeName>System.Serializable</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <Docs> | |
| <summary>Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of <see cref="T:System.IO.FileStream" /> objects. This class cannot be inherited.</summary> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| Use the <xref:System.IO.FileInfo> 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 <xref:System.IO.FileInfo> instance methods instead of the corresponding static methods of the <xref:System.IO.File> class, because a security check will not always be necessary. | |
| Many of the <xref:System.IO.FileInfo> 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 <xref:System.IO.FileInfo> members such as <xref:System.IO.FileInfo.Open%2A>, <xref:System.IO.FileInfo.OpenRead%2A>, <xref:System.IO.FileInfo.OpenText%2A>, <xref:System.IO.FileInfo.CreateText%2A>, or <xref:System.IO.FileInfo.Create%2A>. | |
| 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 <xref:System.IO.FileInfo> methods. | |
| |Enumeration|Description| | |
| |-----------------|-----------------| | |
| |<xref:System.IO.FileAccess>|Specifies read and write access to a file.| | |
| |<xref:System.IO.FileShare>|Specifies the level of access permitted for a file that is already in use.| | |
| |<xref:System.IO.FileMode>|Specifies whether the contents of an existing file are preserved or overwritten, and whether requests to create an existing file cause an exception.| | |
| > [!NOTE] | |
| > 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 <xref:System.IO.FileInfo> 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 <xref:System.IO.FileInfo.Directory%2A> property retrieves an object that represents the parent directory of a file. | |
| - The <xref:System.IO.FileInfo.DirectoryName%2A> property retrieves the full path of the parent directory of a file. | |
| - The <xref:System.IO.FileInfo.Exists%2A> property checks for the presence of a file before operating on it. | |
| - The <xref:System.IO.FileInfo.IsReadOnly%2A> property retrieves or sets a value that specifies whether a file can be modified. | |
| - The <xref:System.IO.FileInfo.Length%2A> retrieves the size of a file. | |
| - The <xref:System.IO.FileInfo.Name%2A> retrieves the name of a file. | |
| ## Examples | |
| The following example demonstrates some of the main members of the `FileInfo` class. | |
| When the properties are first retrieved, <xref:System.IO.FileInfo> calls the <xref:System.IO.FileSystemInfo.Refresh%2A> method and caches information about the file. On subsequent calls, you must call <xref:System.IO.FileSystemInfo.Refresh%2A> to get the latest copy of the information. | |
| [!code-cpp[FInfo Class#1](~/samples/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp#1)] | |
| [!code-csharp[FInfo Class#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Class/CS/finfo class.cs#1)] | |
| [!code-vb[FInfo Class#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Class/VB/finfo class.vb#1)] | |
| This example produces output similar to the following. | |
| ``` | |
| Hello | |
| And | |
| Welcome | |
| C:\Users\userName\AppData\Local\Temp\tmp70AB.tmp was copied to C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp. | |
| C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. | |
| ``` | |
| ]]></format> | |
| </remarks> | |
| <altmember cref="T:System.IO.FileSystemWatcher" /> | |
| <altmember cref="T:System.IO.DriveInfo" /> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| <Members> | |
| <Member MemberName=".ctor"> | |
| <MemberSignature Language="C#" Value="public FileInfo (string fileName);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string fileName) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.#ctor(System.String)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub New (fileName As String)" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 FileInfo(System::String ^ fileName);" /> | |
| <MemberSignature Language="F#" Value="new System.IO.FileInfo : string -> System.IO.FileInfo" Usage="new System.IO.FileInfo fileName" /> | |
| <MemberType>Constructor</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <Parameters> | |
| <Parameter Name="fileName" Type="System.String" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="fileName">The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character.</param> | |
| <summary>Initializes a new instance of the <see cref="T:System.IO.FileInfo" /> class, which acts as a wrapper for a file path.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Ctor/CS/finfo ctor.cs#1)] | |
| [!code-vb[finfo ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Ctor/VB/finfo ctor.vb#1)] | |
| The following example opens an existing file or creates a file, appends text to the file, and displays the results. | |
| [!code-cpp[fileinfomain#1](~/samples/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp#1)] | |
| [!code-csharp[fileinfomain#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfomain/CS/fileinfomain.cs#1)] | |
| [!code-vb[fileinfomain#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfomain/VB/fileinfomain.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <paramref name="fileName" /> is <see langword="null" />.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.ArgumentException">The file name is empty, contains only white spaces, or contains invalid characters.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">Access to <paramref name="fileName" /> is denied.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception> | |
| <exception cref="T:System.NotSupportedException"> | |
| <paramref name="fileName" /> contains a colon (:) in the middle of the string.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="AppendText"> | |
| <MemberSignature Language="C#" Value="public System.IO.StreamWriter AppendText ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.StreamWriter AppendText() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.AppendText" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function AppendText () As StreamWriter" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::StreamWriter ^ AppendText();" /> | |
| <MemberSignature Language="F#" Value="member this.AppendText : unit -> System.IO.StreamWriter" Usage="fileInfo.AppendText " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.StreamWriter</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a <see cref="T:System.IO.StreamWriter" /> that appends text to the file represented by this instance of the <see cref="T:System.IO.FileInfo" />.</summary> | |
| <returns>A new <see langword="StreamWriter" />.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo appendtext#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo AppendText/CS/finfo appendtext.cs#1)] | |
| [!code-vb[finfo appendtext#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo AppendText/VB/finfo appendtext.vb#1)] | |
| The following example demonstrates appending text to the end of a file and also displays the result of the append operation to the console. The first time this routine is called, the file is created if it does not exist. After that, the specified text is appended to the file. | |
| [!code-cpp[fileinfoappendtext#1](~/samples/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp#1)] | |
| [!code-csharp[fileinfoappendtext#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfoappendtext/CS/fileinfoappendtext.cs#1)] | |
| [!code-vb[fileinfoappendtext#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfoappendtext/VB/fileinfoappendtext.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <altmember cref="T:System.IO.StreamWriter" /> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <MemberGroup MemberName="CopyTo"> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Docs> | |
| <summary>Copies an existing file to a new file.</summary> | |
| </Docs> | |
| </MemberGroup> | |
| <Member MemberName="CopyTo"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileInfo CopyTo (string destFileName);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileInfo CopyTo(string destFileName) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.CopyTo(System.String)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function CopyTo (destFileName As String) As FileInfo" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileInfo ^ CopyTo(System::String ^ destFileName);" /> | |
| <MemberSignature Language="F#" Value="member this.CopyTo : string -> System.IO.FileInfo" Usage="fileInfo.CopyTo destFileName" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileInfo</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destFileName" Type="System.String" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destFileName">The name of the new file to copy to.</param> | |
| <summary>Copies an existing file to a new file, disallowing the overwriting of an existing file.</summary> | |
| <returns>A new file with a fully qualified path.</returns> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| Use the <xref:System.IO.FileInfo.CopyTo(System.String,System.Boolean)> method to allow overwriting of an existing file. | |
| > [!CAUTION] | |
| > 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 | |
| ## Examples | |
| The following example demonstrates both overloads of the `CopyTo` method. | |
| [!code-cpp[finfo copyto2#1](~/samples/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp#1)] | |
| [!code-csharp[finfo copyto2#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo CopyTo2/CS/program.cs#1)] | |
| [!code-vb[finfo copyto2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo CopyTo2/VB/program.vb#1)] | |
| The following example demonstrates copying one file to another file, throwing an exception if the destination file already exists. | |
| [!code-cpp[FileInfoCopyTo1#1](~/samples/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp#1)] | |
| [!code-csharp[FileInfoCopyTo1#1](~/samples/snippets/csharp/VS_Snippets_CLR/FileInfoCopyTo1/CS/fileinfocopyto1.cs#1)] | |
| [!code-vb[FileInfoCopyTo1#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FileInfoCopyTo1/VB/fileinfocopyto1.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentException"> | |
| <paramref name="destFileName" /> is empty, contains only white spaces, or contains invalid characters.</exception> | |
| <exception cref="T:System.IO.IOException">An error occurs, or the destination file already exists.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <paramref name="destFileName" /> is <see langword="null" />.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">A directory path is passed in, or the file is being moved to a different drive.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The directory specified in <paramref name="destFileName" /> does not exist.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception> | |
| <exception cref="T:System.NotSupportedException"> | |
| <paramref name="destFileName" /> contains a colon (:) within the string but does not specify the volume.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="CopyTo"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileInfo CopyTo (string destFileName, bool overwrite);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileInfo CopyTo(string destFileName, bool overwrite) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.CopyTo(System.String,System.Boolean)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function CopyTo (destFileName As String, overwrite As Boolean) As FileInfo" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileInfo ^ CopyTo(System::String ^ destFileName, bool overwrite);" /> | |
| <MemberSignature Language="F#" Value="member this.CopyTo : string * bool -> System.IO.FileInfo" Usage="fileInfo.CopyTo (destFileName, overwrite)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileInfo</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destFileName" Type="System.String" /> | |
| <Parameter Name="overwrite" Type="System.Boolean" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destFileName">The name of the new file to copy to.</param> | |
| <param name="overwrite"> | |
| <see langword="true" /> to allow an existing file to be overwritten; otherwise, <see langword="false" />.</param> | |
| <summary>Copies an existing file to a new file, allowing the overwriting of an existing file.</summary> | |
| <returns>A new file, or an overwrite of an existing file if <paramref name="overwrite" /> is <see langword="true" />. If the file exists and <paramref name="overwrite" /> is <see langword="false" />, an <see cref="T:System.IO.IOException" /> is thrown.</returns> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| Use this method to allow or prevent overwriting of an existing file. Use the <xref:System.IO.FileInfo.CopyTo(System.String)> method to prevent overwriting of an existing file by default. | |
| > [!CAUTION] | |
| > 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 | |
| ## Examples | |
| The following example demonstrates both overloads of the `CopyTo` method. | |
| [!code-cpp[finfo copyto2#1](~/samples/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp#1)] | |
| [!code-csharp[finfo copyto2#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo CopyTo2/CS/program.cs#1)] | |
| [!code-vb[finfo copyto2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo CopyTo2/VB/program.vb#1)] | |
| The following example demonstrates copying one file to another file, specifying whether to overwrite a file that already exists. | |
| [!code-cpp[fileinfocopyto#1](~/samples/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp#1)] | |
| [!code-csharp[fileinfocopyto#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfocopyto/CS/fileinfocopyto.cs#1)] | |
| [!code-vb[fileinfocopyto#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfocopyto/VB/fileinfocopyto.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentException"> | |
| <paramref name="destFileName" /> is empty, contains only white spaces, or contains invalid characters.</exception> | |
| <exception cref="T:System.IO.IOException">An error occurs, or the destination file already exists and <paramref name="overwrite" /> is <see langword="false" />.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <paramref name="destFileName" /> is <see langword="null" />.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The directory specified in <paramref name="destFileName" /> does not exist.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">A directory path is passed in, or the file is being moved to a different drive.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception> | |
| <exception cref="T:System.NotSupportedException"> | |
| <paramref name="destFileName" /> contains a colon (:) in the middle of the string.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Create"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream Create ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream Create() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Create" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Create () As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ Create();" /> | |
| <MemberSignature Language="F#" Value="member this.Create : unit -> System.IO.FileStream" Usage="fileInfo.Create " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a file.</summary> | |
| <returns>A new file.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[fileinfodelete#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfodelete/CS/fileinfodelete.cs#1)] | |
| [!code-vb[fileinfodelete#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfodelete/VB/fileinfodelete.vb#1)] | |
| The following example creates a file, adds some text to it, and reads from the file. | |
| [!code-cpp[finfo create#1](~/samples/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp#1)] | |
| [!code-csharp[finfo create#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Create/CS/finfo create.cs#1)] | |
| [!code-vb[finfo create#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Create/VB/finfo create.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="CreateText"> | |
| <MemberSignature Language="C#" Value="public System.IO.StreamWriter CreateText ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.StreamWriter CreateText() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.CreateText" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function CreateText () As StreamWriter" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::StreamWriter ^ CreateText();" /> | |
| <MemberSignature Language="F#" Value="member this.CreateText : unit -> System.IO.StreamWriter" Usage="fileInfo.CreateText " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.StreamWriter</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a <see cref="T:System.IO.StreamWriter" /> that writes a new text file.</summary> | |
| <returns>A new <see langword="StreamWriter" />.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo createtext#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo CreateText/CS/finfo createtext.cs#1)] | |
| [!code-vb[finfo createtext#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo CreateText/VB/finfo createtext.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.UnauthorizedAccessException">The file name is a directory.</exception> | |
| <exception cref="T:System.IO.IOException">The disk is read-only.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <altmember cref="T:System.IO.StreamWriter" /> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Decrypt"> | |
| <MemberSignature Language="C#" Value="public void Decrypt ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Decrypt() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Decrypt" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub Decrypt ()" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 void Decrypt();" /> | |
| <MemberSignature Language="F#" Value="member this.Decrypt : unit -> unit" Usage="fileInfo.Decrypt " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Decrypts a file that was encrypted by the current account using the <see cref="M:System.IO.FileInfo.Encrypt" /> method.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.Encrypt-Decrypt#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.Encrypt-Decrypt#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.</exception> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.</exception> | |
| <exception cref="T:System.NotSupportedException">The file system is not NTFS.</exception> | |
| <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">The file described by the current <see cref="T:System.IO.FileInfo" /> object is read-only. | |
| -or- | |
| This operation is not supported on the current platform. | |
| -or- | |
| The caller does not have the required permission.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Delete"> | |
| <MemberSignature Language="C#" Value="public override void Delete ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Delete() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Delete" /> | |
| <MemberSignature Language="VB.NET" Value="Public Overrides Sub Delete ()" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 override void Delete();" /> | |
| <MemberSignature Language="F#" Value="override this.Delete : unit -> unit" Usage="fileInfo.Delete " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Permanently deletes a file.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo delete#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Delete/CS/finfo delete.cs#1)] | |
| [!code-vb[finfo delete#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Delete/VB/finfo delete.vb#1)] | |
| The following example creates, closes, and deletes a file. | |
| [!code-cpp[fileinfodelete#1](~/samples/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp#1)] | |
| [!code-csharp[fileinfodelete#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfodelete/CS/fileinfodelete.cs#1)] | |
| [!code-vb[fileinfodelete#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfodelete/VB/fileinfodelete.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException">The target file is open or memory-mapped on a computer running Microsoft Windows NT. | |
| -or- | |
| There is an open handle on the file, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see [How to: Enumerate Directories and Files](/dotnet/standard/io/how-to-enumerate-directories-and-files).</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">The path is a directory.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Directory"> | |
| <MemberSignature Language="C#" Value="public System.IO.DirectoryInfo Directory { get; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance class System.IO.DirectoryInfo Directory" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.Directory" /> | |
| <MemberSignature Language="VB.NET" Value="Public ReadOnly Property Directory As DirectoryInfo" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 property System::IO::DirectoryInfo ^ Directory { System::IO::DirectoryInfo ^ get(); };" /> | |
| <MemberSignature Language="F#" Value="member this.Directory : System.IO.DirectoryInfo" Usage="System.IO.FileInfo.Directory" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>get: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.DirectoryInfo</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets an instance of the parent directory.</summary> | |
| <value>A <see cref="T:System.IO.DirectoryInfo" /> object representing the parent directory of this file.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[fileinfodirectory#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfodirectory/CS/fileinfodirectory.cs#1)] | |
| [!code-vb[fileinfodirectory#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfodirectory/VB/fileinfodirectory.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="DirectoryName"> | |
| <MemberSignature Language="C#" Value="public string DirectoryName { get; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance string DirectoryName" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.DirectoryName" /> | |
| <MemberSignature Language="VB.NET" Value="Public ReadOnly Property DirectoryName As String" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ DirectoryName { System::String ^ get(); };" /> | |
| <MemberSignature Language="F#" Value="member this.DirectoryName : string" Usage="System.IO.FileInfo.DirectoryName" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>get: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.String</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets a string representing the directory's full path.</summary> | |
| <value>A string representing the directory's full path.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[System.IO.FileInfo members#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.IO.FileInfo members/CS/fileinfomembers.cs#3)] | |
| [!code-vb[System.IO.FileInfo members#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb#3)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <see langword="null" /> was passed in for the directory name.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The fully qualified path name exceeds the system-defined maximum length.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Encrypt"> | |
| <MemberSignature Language="C#" Value="public void Encrypt ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Encrypt() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Encrypt" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub Encrypt ()" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 void Encrypt();" /> | |
| <MemberSignature Language="F#" Value="member this.Encrypt : unit -> unit" Usage="fileInfo.Encrypt " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Encrypts a file so that only the account used to encrypt the file can decrypt it.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.Encrypt-Decrypt#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.Encrypt-Decrypt#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.</exception> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.</exception> | |
| <exception cref="T:System.NotSupportedException">The file system is not NTFS.</exception> | |
| <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">The file described by the current <see cref="T:System.IO.FileInfo" /> object is read-only. | |
| -or- | |
| This operation is not supported on the current platform. | |
| -or- | |
| The caller does not have the required permission.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Exists"> | |
| <MemberSignature Language="C#" Value="public override bool Exists { get; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance bool Exists" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.Exists" /> | |
| <MemberSignature Language="VB.NET" Value="Public Overrides ReadOnly Property Exists As Boolean" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 virtual property bool Exists { bool get(); };" /> | |
| <MemberSignature Language="F#" Value="member this.Exists : bool" Usage="System.IO.FileInfo.Exists" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>get: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Boolean</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets a value indicating whether a file exists.</summary> | |
| <value> | |
| <see langword="true" /> if the file exists; <see langword="false" /> if the file does not exist or if the file is a directory.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.Exists#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.Exists/cs/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.Exists#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Exists/vb/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <MemberGroup MemberName="GetAccessControl"> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Docs> | |
| <summary>Gets a <see cref="T:System.Security.AccessControl.FileSecurity" /> object that encapsulates the access control list (ACL) entries for the file described by the current <see cref="T:System.IO.FileInfo" /> object.</summary> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| Use the <xref:System.IO.FileInfo.GetAccessControl%2A> methods to retrieve the access control list (ACL) entries for the current file. | |
| ]]></format> | |
| </remarks> | |
| </Docs> | |
| </MemberGroup> | |
| <Member MemberName="GetAccessControl"> | |
| <MemberSignature Language="C#" Value="public System.Security.AccessControl.FileSecurity GetAccessControl ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Security.AccessControl.FileSecurity GetAccessControl() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.GetAccessControl" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function GetAccessControl () As FileSecurity" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::Security::AccessControl::FileSecurity ^ GetAccessControl();" /> | |
| <MemberSignature Language="F#" Value="member this.GetAccessControl : unit -> System.Security.AccessControl.FileSecurity" Usage="fileInfo.GetAccessControl " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.Security.AccessControl.FileSecurity</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Gets a <see cref="T:System.Security.AccessControl.FileSecurity" /> object that encapsulates the access control list (ACL) entries for the file described by the current <see cref="T:System.IO.FileInfo" /> object.</summary> | |
| <returns>A <see cref="T:System.Security.AccessControl.FileSecurity" /> object that encapsulates the access control rules for the current file.</returns> | |
| <remarks> | |
| <format type="text/markdown"><. | |
| ## Examples | |
| The following code example uses the <xref:System.IO.FileInfo.GetAccessControl%2A> method and the <xref:System.IO.FileInfo.SetAccessControl%2A> method to add and then remove an access control list (ACL) entry from a file. You must supply a valid user or group account to run this example. | |
| [!code-cpp[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp#1)] | |
| [!code-csharp[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.</exception> | |
| <exception cref="T:System.Security.AccessControl.PrivilegeNotHeldException">The current system account does not have administrative privileges.</exception> | |
| <exception cref="T:System.SystemException">The file could not be found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">This operation is not supported on the current platform. | |
| -or- | |
| The caller does not have the required permission.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="GetAccessControl"> | |
| <MemberSignature Language="C#" Value="public System.Security.AccessControl.FileSecurity GetAccessControl (System.Security.AccessControl.AccessControlSections includeSections);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Security.AccessControl.FileSecurity GetAccessControl(valuetype System.Security.AccessControl.AccessControlSections includeSections) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.GetAccessControl(System.Security.AccessControl.AccessControlSections)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function GetAccessControl (includeSections As AccessControlSections) As FileSecurity" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::Security::AccessControl::FileSecurity ^ GetAccessControl(System::Security::AccessControl::AccessControlSections includeSections);" /> | |
| <MemberSignature Language="F#" Value="member this.GetAccessControl : System.Security.AccessControl.AccessControlSections -> System.Security.AccessControl.FileSecurity" Usage="fileInfo.GetAccessControl includeSections" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.Security.AccessControl.FileSecurity</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="includeSections" Type="System.Security.AccessControl.AccessControlSections" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="includeSections">One of the <see cref="T:System.Security.AccessControl.AccessControlSections" /> values that specifies which group of access control entries to retrieve.</param> | |
| <summary>Gets a <see cref="T:System.Security.AccessControl.FileSecurity" /> object that encapsulates the specified type of access control list (ACL) entries for the file described by the current <see cref="T:System.IO.FileInfo" /> object.</summary> | |
| <returns>A <see cref="T:System.Security.AccessControl.FileSecurity" /> object that encapsulates the access control rules for the current file.</returns> | |
| <remarks> | |
| <format type="text/markdown"><. | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.</exception> | |
| <exception cref="T:System.Security.AccessControl.PrivilegeNotHeldException">The current system account does not have administrative privileges.</exception> | |
| <exception cref="T:System.SystemException">The file could not be found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">This operation is not supported on the current platform. | |
| -or- | |
| The caller does not have the required permission.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="IsReadOnly"> | |
| <MemberSignature Language="C#" Value="public bool IsReadOnly { get; set; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance bool IsReadOnly" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.IsReadOnly" /> | |
| <MemberSignature Language="VB.NET" Value="Public Property IsReadOnly As Boolean" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 property bool IsReadOnly { bool get(); void set(bool value); };" /> | |
| <MemberSignature Language="F#" Value="member this.IsReadOnly : bool with get, set" Usage="System.IO.FileInfo.IsReadOnly" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>get: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>set: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Boolean</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets or sets a value that determines if the current file is read only.</summary> | |
| <value> | |
| <see langword="true" /> if the current file is read only; otherwise, <see langword="false" />.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.IsReadOnly#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.IsReadOnly#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.isReadOnly/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.</exception> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">This operation is not supported on the current platform. | |
| -or- | |
| The caller does not have the required permission.</exception> | |
| <exception cref="T:System.ArgumentException">The user does not have write permission, but attempted to set this property to <see langword="false" />.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Length"> | |
| <MemberSignature Language="C#" Value="public long Length { get; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance int64 Length" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.Length" /> | |
| <MemberSignature Language="VB.NET" Value="Public ReadOnly Property Length As Long" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 property long Length { long get(); };" /> | |
| <MemberSignature Language="F#" Value="member this.Length : int64" Usage="System.IO.FileInfo.Length" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>get: System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Int64</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets the size, in bytes, of the current file.</summary> | |
| <value>The size of the current file in bytes.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[FileLength#1](~/samples/snippets/csharp/VS_Snippets_CLR/FileLength/CS/filelength.cs#1)] | |
| [!code-vb[FileLength#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FileLength/VB/filelength.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException"> | |
| <see cref="M:System.IO.FileSystemInfo.Refresh" /> cannot update the state of the file or directory.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file does not exist. | |
| -or- | |
| The <see langword="Length" /> property is called for a directory.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="MoveTo"> | |
| <MemberSignature Language="C#" Value="public void MoveTo (string destFileName);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void MoveTo(string destFileName) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.MoveTo(System.String)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub MoveTo (destFileName As String)" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 void MoveTo(System::String ^ destFileName);" /> | |
| <MemberSignature Language="F#" Value="member this.MoveTo : string -> unit" Usage="fileInfo.MoveTo destFileName" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destFileName" Type="System.String" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destFileName">The path to move the file to, which can specify a different file name.</param> | |
| <summary>Moves a specified file to a new location, providing the option to specify a new file name.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-vb[IO.FileInfo.MoveTo#1](~/samples/snippets/visualbasic/VS_Snippets_Misc/IO.FileInfo.MoveTo/VB/Program.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException">An I/O error occurs, such as the destination file already exists or the destination device is not ready.</exception> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <paramref name="destFileName" /> is <see langword="null" />.</exception> | |
| <exception cref="T:System.ArgumentException"> | |
| <paramref name="destFileName" /> is empty, contains only white spaces, or contains invalid characters.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <paramref name="destFileName" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception> | |
| <exception cref="T:System.NotSupportedException"> | |
| <paramref name="destFileName" /> contains a colon (:) in the middle of the string.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="MoveTo"> | |
| <MemberSignature Language="C#" Value="public void MoveTo (string destFileName, bool overwrite);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void MoveTo(string destFileName, bool overwrite) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.MoveTo(System.String,System.Boolean)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub MoveTo (destFileName As String, overwrite As Boolean)" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 void MoveTo(System::String ^ destFileName, bool overwrite);" /> | |
| <MemberSignature Language="F#" Value="member this.MoveTo : string * bool -> unit" Usage="fileInfo.MoveTo (destFileName, overwrite)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destFileName" Type="System.String" Index="0" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0" /> | |
| <Parameter Name="overwrite" Type="System.Boolean" Index="1" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destFileName">The path to move the file to, which can specify a different file name.</param> | |
| <param name="overwrite"> | |
| <see langword="true" /> to overwrite the destination file if it already exists; <see langword="false" /> otherwise.</param> | |
| <summary>Moves a specified file to a new location, providing the options to specify a new file name and to overwrite the destination file if it already exists.</summary> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-vb[IO.FileInfo.MoveTo#1](~/samples/snippets/visualbasic/VS_Snippets_Misc/IO.FileInfo.MoveTo/VB/Program.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.IOException">An I/O error occurred, such as the destination device is not ready.</exception> | |
| <exception cref="T:System.ArgumentNullException"> | |
| <paramref name="destFileName" /> is <see langword="null" />.</exception> | |
| <exception cref="T:System.ArgumentException"> | |
| <paramref name="destFileName" /> is empty, contains only white spaces, or contains invalid characters.</exception> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <paramref name="destFileName" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception> | |
| <exception cref="T:System.NotSupportedException"> | |
| <paramref name="destFileName" /> contains a colon (:) in the middle of the string.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Name"> | |
| <MemberSignature Language="C#" Value="public override string Name { get; }" /> | |
| <MemberSignature Language="ILAsm" Value=".property instance string Name" /> | |
| <MemberSignature Language="DocId" Value="P:System.IO.FileInfo.Name" /> | |
| <MemberSignature Language="VB.NET" Value="Public Overrides ReadOnly Property Name As String" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 virtual property System::String ^ Name { System::String ^ get(); };" /> | |
| <MemberSignature Language="F#" Value="member this.Name : string" Usage="System.IO.FileInfo.Name" /> | |
| <MemberType>Property</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.String</ReturnType> | |
| </ReturnValue> | |
| <Docs> | |
| <summary>Gets the name of the file.</summary> | |
| <value>The name of the file.</value> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[fileinfoname#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfoname/CS/fileinfoname.cs#1)] | |
| [!code-vb[fileinfoname#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfoname/VB/fileinfoname.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <MemberGroup MemberName="Open"> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Docs> | |
| <summary>Opens a file with various read/write and sharing privileges.</summary> | |
| </Docs> | |
| </MemberGroup> | |
| <Member MemberName="Open"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream Open (System.IO.FileMode mode);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream Open(valuetype System.IO.FileMode mode) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Open(System.IO.FileMode)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Open (mode As FileMode) As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ Open(System::IO::FileMode mode);" /> | |
| <MemberSignature Language="F#" Value="member this.Open : System.IO.FileMode -> System.IO.FileStream" Usage="fileInfo.Open mode" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="mode" Type="System.IO.FileMode" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="mode">A <see cref="T:System.IO.FileMode" /> constant specifying the mode (for example, <see langword="Open" /> or <see langword="Append" />) in which to open the file.</param> | |
| <summary>Opens a file in the specified mode.</summary> | |
| <returns>A file opened in the specified mode, with read/write access and unshared.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo open1#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Open1/CS/finfo open1.cs#1)] | |
| [!code-vb[finfo open1#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Open1/VB/finfo open1.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">The file is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.IOException">The file is already open.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Open"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream Open (System.IO.FileMode mode, System.IO.FileAccess access);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream Open(valuetype System.IO.FileMode mode, valuetype System.IO.FileAccess access) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Open(System.IO.FileMode,System.IO.FileAccess)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Open (mode As FileMode, access As FileAccess) As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ Open(System::IO::FileMode mode, System::IO::FileAccess access);" /> | |
| <MemberSignature Language="F#" Value="member this.Open : System.IO.FileMode * System.IO.FileAccess -> System.IO.FileStream" Usage="fileInfo.Open (mode, access)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="mode" Type="System.IO.FileMode" /> | |
| <Parameter Name="access" Type="System.IO.FileAccess" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="mode">A <see cref="T:System.IO.FileMode" /> constant specifying the mode (for example, <see langword="Open" /> or <see langword="Append" />) in which to open the file.</param> | |
| <param name="access">A <see cref="T:System.IO.FileAccess" /> constant specifying whether to open the file with <see langword="Read" />, <see langword="Write" />, or <see langword="ReadWrite" /> file access.</param> | |
| <summary>Opens a file in the specified mode with read, write, or read/write access.</summary> | |
| <returns>A <see cref="T:System.IO.FileStream" /> object opened in the specified mode and access, and unshared.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo open2#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo Open2/CS/finfo open2.cs#1)] | |
| [!code-vb[finfo open2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo Open2/VB/finfo open2.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.IOException">The file is already open.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <exception cref="T:System.ArgumentException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is empty or contains only white spaces.</exception> | |
| <exception cref="T:System.ArgumentNullException">One or more arguments is null.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Open"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream Open (System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream Open(valuetype System.IO.FileMode mode, valuetype System.IO.FileAccess access, valuetype System.IO.FileShare share) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Open(System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Open (mode As FileMode, access As FileAccess, share As FileShare) As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ Open(System::IO::FileMode mode, System::IO::FileAccess access, System::IO::FileShare share);" /> | |
| <MemberSignature Language="F#" Value="member this.Open : System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare -> System.IO.FileStream" Usage="fileInfo.Open (mode, access, share)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="mode" Type="System.IO.FileMode" /> | |
| <Parameter Name="access" Type="System.IO.FileAccess" /> | |
| <Parameter Name="share" Type="System.IO.FileShare" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="mode">A <see cref="T:System.IO.FileMode" /> constant specifying the mode (for example, <see langword="Open" /> or <see langword="Append" />) in which to open the file.</param> | |
| <param name="access">A <see cref="T:System.IO.FileAccess" /> constant specifying whether to open the file with <see langword="Read" />, <see langword="Write" />, or <see langword="ReadWrite" /> file access.</param> | |
| <param name="share">A <see cref="T:System.IO.FileShare" /> constant specifying the type of access other <see langword="FileStream" /> objects have to this file.</param> | |
| <summary>Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.</summary> | |
| <returns>A <see cref="T:System.IO.FileStream" /> object opened with the specified mode, access, and sharing options.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[fileinfoopen#1](~/samples/snippets/csharp/VS_Snippets_CLR/fileinfoopen/CS/fileinfoopen.cs#1)] | |
| [!code-vb[fileinfoopen#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/fileinfoopen/VB/fileinfoopen.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.IOException">The file is already open.</exception> | |
| <exception cref="T:System.ArgumentException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is empty or contains only white spaces.</exception> | |
| <exception cref="T:System.ArgumentNullException">One or more arguments is null.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="OpenRead"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream OpenRead ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream OpenRead() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.OpenRead" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function OpenRead () As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ OpenRead();" /> | |
| <MemberSignature Language="F#" Value="member this.OpenRead : unit -> System.IO.FileStream" Usage="fileInfo.OpenRead " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a read-only <see cref="T:System.IO.FileStream" />.</summary> | |
| <returns>A new read-only <see cref="T:System.IO.FileStream" /> object.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo openread#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo OpenRead/CS/finfo openread.cs#1)] | |
| [!code-vb[finfo openread#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenRead/VB/finfo openread.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <exception cref="T:System.IO.IOException">The file is already open.</exception> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="OpenText"> | |
| <MemberSignature Language="C#" Value="public System.IO.StreamReader OpenText ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.StreamReader OpenText() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.OpenText" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function OpenText () As StreamReader" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::StreamReader ^ OpenText();" /> | |
| <MemberSignature Language="F#" Value="member this.OpenText : unit -> System.IO.StreamReader" Usage="fileInfo.OpenText " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.StreamReader</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a <see cref="T:System.IO.StreamReader" /> with UTF8 encoding that reads from an existing text file.</summary> | |
| <returns>A new <see langword="StreamReader" /> with UTF8 encoding.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo opentext#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo OpenText/CS/file opentext.cs#1)] | |
| [!code-vb[finfo opentext#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenText/VB/file opentext.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException"> | |
| <see cref="P:System.IO.FileInfo.Name" /> is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception> | |
| <altmember cref="P:System.Text.Encoding.UTF8" /> | |
| <altmember cref="T:System.IO.StreamReader" /> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file">How to: Read and Write to a Newly Created Data File</related> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="OpenWrite"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileStream OpenWrite ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileStream OpenWrite() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.OpenWrite" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function OpenWrite () As FileStream" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileStream ^ OpenWrite();" /> | |
| <MemberSignature Language="F#" Value="member this.OpenWrite : unit -> System.IO.FileStream" Usage="fileInfo.OpenWrite " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileStream</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Creates a write-only <see cref="T:System.IO.FileStream" />.</summary> | |
| <returns>A write-only unshared <see cref="T:System.IO.FileStream" /> object for a new or existing file.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[finfo openwrite#1](~/samples/snippets/csharp/VS_Snippets_CLR/FInfo OpenWrite/CS/file openwrite.cs#1)] | |
| [!code-vb[finfo openwrite#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenWrite/VB/file openwrite.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.UnauthorizedAccessException">The path specified when creating an instance of the <see cref="T:System.IO.FileInfo" /> object is read-only or is a directory.</exception> | |
| <exception cref="T:System.IO.DirectoryNotFoundException">The path specified when creating an instance of the <see cref="T:System.IO.FileInfo" /> object is invalid, such as being on an unmapped drive.</exception> | |
| </Docs> | |
| </Member> | |
| <MemberGroup MemberName="Replace"> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Docs> | |
| <summary>Replaces the contents of a specified file with the file described by the current <see cref="T:System.IO.FileInfo" /> object, deleting the original file, and creating a backup of the replaced file.</summary> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| Use the <xref:System.IO.FileInfo.Replace%2A> methods when you need to quickly replace a file with the contents of the file described by the current <xref:System.IO.FileInfo> object. | |
| ]]></format> | |
| </remarks> | |
| </Docs> | |
| </MemberGroup> | |
| <Member MemberName="Replace"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileInfo Replace (string destinationFileName, string destinationBackupFileName);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileInfo Replace(string destinationFileName, string destinationBackupFileName) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Replace(System.String,System.String)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Replace (destinationFileName As String, destinationBackupFileName As String) As FileInfo" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileInfo ^ Replace(System::String ^ destinationFileName, System::String ^ destinationBackupFileName);" /> | |
| <MemberSignature Language="F#" Value="member this.Replace : string * string -> System.IO.FileInfo" Usage="fileInfo.Replace (destinationFileName, destinationBackupFileName)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName> | |
| </Attribute> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileInfo</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destinationFileName" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1;netcore-3.1;net-5.0" /> | |
| <Parameter Name="destinationBackupFileName" Type="System.String" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1;netcore-3.1;net-5.0" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destinationFileName">The name of a file to replace with the current file.</param> | |
| <param name="destinationBackupFileName">The name of a file with which to create a backup of the file described by the <paramref name="destFileName" /> parameter.</param> | |
| <summary>Replaces the contents of a specified file with the file described by the current <see cref="T:System.IO.FileInfo" /> object, deleting the original file, and creating a backup of the replaced file.</summary> | |
| <returns>A <see cref="T:System.IO.FileInfo" /> object that encapsulates information about the file described by the <paramref name="destFileName" /> parameter.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.Replace#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.Replace/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.Replace#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Replace/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentException">The path described by the <paramref name="destFileName" /> parameter was not of a legal form. | |
| -or- | |
| The path described by the <paramref name="destBackupFileName" /> parameter was not of a legal form.</exception> | |
| <exception cref="T:System.ArgumentNullException">The <paramref name="destFileName" /> parameter is <see langword="null" />.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found. | |
| -or- | |
| The file described by the <paramref name="destinationFileName" /> parameter could not be found.</exception> | |
| <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="Replace"> | |
| <MemberSignature Language="C#" Value="public System.IO.FileInfo Replace (string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.Replace(System.String,System.String,System.Boolean)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Function Replace (destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean) As FileInfo" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 System::IO::FileInfo ^ Replace(System::String ^ destinationFileName, System::String ^ destinationBackupFileName, bool ignoreMetadataErrors);" /> | |
| <MemberSignature Language="F#" Value="member this.Replace : string * string * bool -> System.IO.FileInfo" Usage="fileInfo.Replace (destinationFileName, destinationBackupFileName, ignoreMetadataErrors)" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8"> | |
| <AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName> | |
| </Attribute> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.IO.FileInfo</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="destinationFileName" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1;netcore-3.1;net-5.0" /> | |
| <Parameter Name="destinationBackupFileName" Type="System.String" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1;netcore-3.1;net-5.0" /> | |
| <Parameter Name="ignoreMetadataErrors" Type="System.Boolean" Index="2" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1;netcore-3.1;net-5.0" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="destinationFileName">The name of a file to replace with the current file.</param> | |
| <param name="destinationBackupFileName">The name of a file with which to create a backup of the file described by the <paramref name="destFileName" /> parameter.</param> | |
| <param name="ignoreMetadataErrors"> | |
| <see langword="true" /> to ignore merge errors (such as attributes and ACLs) from the replaced file to the replacement file; otherwise <see langword="false" />.</param> | |
| <summary>Replaces the contents of a specified file with the file described by the current <see cref="T:System.IO.FileInfo" /> object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.</summary> | |
| <returns>A <see cref="T:System.IO.FileInfo" /> object that encapsulates information about the file described by the <paramref name="destFileName" /> parameter.</returns> | |
| <remarks> | |
| <format type="text/markdown"><] | |
| [!code-csharp[IO.FileInfo.Replace#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.Replace/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.Replace#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Replace/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentException">The path described by the <paramref name="destFileName" /> parameter was not of a legal form. | |
| -or- | |
| The path described by the <paramref name="destBackupFileName" /> parameter was not of a legal form.</exception> | |
| <exception cref="T:System.ArgumentNullException">The <paramref name="destFileName" /> parameter is <see langword="null" />.</exception> | |
| <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found. | |
| -or- | |
| The file described by the <paramref name="destinationFileName" /> parameter could not be found.</exception> | |
| <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="SetAccessControl"> | |
| <MemberSignature Language="C#" Value="public void SetAccessControl (System.Security.AccessControl.FileSecurity fileSecurity);" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void SetAccessControl(class System.Security.AccessControl.FileSecurity fileSecurity) cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.SetAccessControl(System.Security.AccessControl.FileSecurity)" /> | |
| <MemberSignature Language="VB.NET" Value="Public Sub SetAccessControl (fileSecurity As FileSecurity)" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 void SetAccessControl(System::Security::AccessControl::FileSecurity ^ fileSecurity);" /> | |
| <MemberSignature Language="F#" Value="member this.SetAccessControl : System.Security.AccessControl.FileSecurity -> unit" Usage="fileInfo.SetAccessControl fileSecurity" /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| </AssemblyInfo> | |
| <Attributes> | |
| <Attribute FrameworkAlternate="netframework-4.0"> | |
| <AttributeName>System.Security.SecuritySafeCritical</AttributeName> | |
| </Attribute> | |
| </Attributes> | |
| <ReturnValue> | |
| <ReturnType>System.Void</ReturnType> | |
| </ReturnValue> | |
| <Parameters> | |
| <Parameter Name="fileSecurity" Type="System.Security.AccessControl.FileSecurity" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" /> | |
| </Parameters> | |
| <Docs> | |
| <param name="fileSecurity">A <see cref="T:System.Security.AccessControl.FileSecurity" /> object that describes an access control list (ACL) entry to apply to the current file.</param> | |
| <summary>Applies access control list (ACL) entries described by a <see cref="T:System.Security.AccessControl.FileSecurity" /> object to the file described by the current <see cref="T:System.IO.FileInfo" /> object.</summary> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| The <xref:System.IO.FileInfo.SetAccessControl%2A> method applies access control list (ACL) entries to the current file that represents the noninherited ACL list. | |
| Use the <xref:System.IO.FileInfo.SetAccessControl%2A> method whenever you need to add or remove ACL entries from a file. | |
| > [!CAUTION] | |
| > The ACL specified for the `fileSecurity` parameter replaces the existing ACL for the file. To add permissions for a new user, use the <xref:System.IO.Directory.GetAccessControl%2A> method to obtain the existing ACL, modify it, and then use <xref:System.IO.FileInfo.SetAccessControl%2A> 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 [How to: Add or Remove Access Control List Entries](/dotnet/standard/io/how-to-add-or-remove-access-control-list-entries). | |
| The <xref:System.IO.FileInfo.SetAccessControl%2A> method persists only <xref:System.Security.AccessControl.FileSecurity> objects that have been modified after object creation. If a <xref:System.Security.AccessControl.FileSecurity> object has not been modified, it will not be persisted to a file. Therefore, it is not possible to retrieve a <xref:System.Security.AccessControl.FileSecurity> object from one file and reapply the same object to another file. | |
| To copy ACL information from one file to another: | |
| 1. Use the <xref:System.IO.FileInfo.GetAccessControl%2A> method to retrieve the <xref:System.Security.AccessControl.FileSecurity> object from the source file. | |
| 2. Create a new <xref:System.Security.AccessControl.FileSecurity> object for the destination file. | |
| 3. Use the <xref:System.Security.AccessControl.ObjectSecurity.GetSecurityDescriptorBinaryForm%2A> or <xref:System.Security.AccessControl.ObjectSecurity.GetSecurityDescriptorSddlForm%2A> method of the source <xref:System.Security.AccessControl.FileSecurity> object to retrieve the ACL information. | |
| 4. Use the <xref:System.Security.AccessControl.ObjectSecurity.SetSecurityDescriptorBinaryForm%2A> or <xref:System.Security.AccessControl.ObjectSecurity.SetSecurityDescriptorSddlForm%2A> method to copy the information retrieved in step 3 to the destination <xref:System.Security.AccessControl.FileSecurity> object. | |
| 5. Set the destination <xref:System.Security.AccessControl.FileSecurity> object to the destination file using the <xref:System.IO.FileInfo.SetAccessControl%2A> method. | |
| ## Examples | |
| The following code example uses the <xref:System.IO.FileInfo.GetAccessControl%2A> method and the <xref:System.IO.FileInfo.SetAccessControl%2A> method to add and then remove an ACL entry from a file. You must supply a valid user or group account to run this example. | |
| [!code-cpp[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp#1)] | |
| [!code-csharp[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/CS/sample.cs#1)] | |
| [!code-vb[IO.FileInfo.GetAccessControl-SetAccessControl#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/VB/sample.vb#1)] | |
| ]]></format> | |
| </remarks> | |
| <exception cref="T:System.ArgumentNullException">The <paramref name="fileSecurity" /> parameter is <see langword="null" />.</exception> | |
| <exception cref="T:System.SystemException">The file could not be found or modified.</exception> | |
| <exception cref="T:System.UnauthorizedAccessException">The current process does not have access to open the file.</exception> | |
| </Docs> | |
| </Member> | |
| <Member MemberName="ToString"> | |
| <MemberSignature Language="C#" Value="public override string ToString ();" /> | |
| <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance string ToString() cil managed" /> | |
| <MemberSignature Language="DocId" Value="M:System.IO.FileInfo.ToString" /> | |
| <MemberSignature Language="VB.NET" Value="Public Overrides Function ToString () As String" /> | |
| <MemberSignature Language="C++ CLI" Value="public:
 override System::String ^ ToString();" /> | |
| <MemberSignature Language="F#" Value="override this.ToString : unit -> string" Usage="fileInfo.ToString " /> | |
| <MemberType>Method</MemberType> | |
| <AssemblyInfo> | |
| <AssemblyName>System.IO.FileSystem</AssemblyName> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.0.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.1.0</AssemblyVersion> | |
| <AssemblyVersion>4.1.2.0</AssemblyVersion> | |
| <AssemblyVersion>5.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>mscorlib</AssemblyName> | |
| <AssemblyVersion>1.0.5000.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.0.5.0</AssemblyVersion> | |
| <AssemblyVersion>4.0.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <AssemblyInfo> | |
| <AssemblyName>netstandard</AssemblyName> | |
| <AssemblyVersion>2.0.0.0</AssemblyVersion> | |
| <AssemblyVersion>2.1.0.0</AssemblyVersion> | |
| </AssemblyInfo> | |
| <ReturnValue> | |
| <ReturnType>System.String</ReturnType> | |
| </ReturnValue> | |
| <Parameters /> | |
| <Docs> | |
| <summary>Returns the path as a string. Use the <see cref="P:System.IO.FileInfo.Name" /> property for the full path.</summary> | |
| <returns>A string representing the path.</returns> | |
| <remarks> | |
| <format type="text/markdown"><![CDATA[ | |
| ## Remarks | |
| > [!IMPORTANT] | |
| > The string returned by the <xref:System.IO.FileInfo.ToString%2A> method represents the path that was passed to the <xref:System.IO.FileInfo> constructor. Instead of calling the `ToString` method, you should retrieve the value of either of the following properties, depending on your intent: | |
| > - <xref:System.IO.FileInfo.Name>, to get the name of the file, without any parent path information. | |
| > - [FullName](xref:System.IO.FileSystemInfo.FullName), to get the fully qualified path of the file. | |
| ]]></format> | |
| </remarks> | |
| <related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related> | |
| <related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related> | |
| </Docs> | |
| </Member> | |
| </Members> | |
| </Type> |