You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.IO/File.xml
+20-46Lines changed: 20 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -77,9 +77,9 @@
77
77
78
78
Many of the <xref:System.IO.File> 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.File> members such as <xref:System.IO.File.OpenText%2A>, <xref:System.IO.File.CreateText%2A>, or <xref:System.IO.File.Create%2A>.
79
79
80
-
Because all <xref:System.IO.File> methods are static, it might be more efficient to use a <xref:System.IO.File> method rather than a corresponding <xref:System.IO.FileInfo> instance method if you want to perform only one action. All <xref:System.IO.File> methods require the path to the file that you are manipulating.
80
+
Because all <xref:System.IO.File> methods are static, if you want to perform only one action, it might be more efficient to use a <xref:System.IO.File> method than a corresponding <xref:System.IO.FileInfo> instance method. All <xref:System.IO.File> methods require the path to the file that you are manipulating.
81
81
82
-
The static methods of the <xref:System.IO.File> class perform security checks on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of <xref:System.IO.FileInfo> instead, because the security check will not always be necessary.
82
+
The static methods of the <xref:System.IO.File> class perform security checks on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of <xref:System.IO.FileInfo> instead, because the security check won't always be necessary.
83
83
84
84
By default, full read/write access to new files is granted to all users.
85
85
@@ -97,17 +97,12 @@
97
97
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:
98
98
99
99
- `"c:\\\MyDir\\\MyFile.txt"` in C#, or `"c:\MyDir\MyFile.txt"` in Visual Basic.
100
-
101
100
- `"c:\\\MyDir"` in C#, or `"c:\MyDir"` in Visual Basic.
102
-
103
101
- `"MyDir\\\MySubdir"` in C#, or `"MyDir\MySubDir"` in Visual Basic.
104
-
105
102
- `"\\\\\\\MyServer\\\MyShare"` in C#, or `"\\\MyServer\MyShare"` in Visual Basic.
106
103
107
104
For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks).
108
105
109
-
110
-
111
106
## Examples
112
107
The following example demonstrates how to use the <xref:System.IO.File> class to check whether a file exists, and depending on the result, either create a new file and write to it, or open the existing file and read from it. Before running the code, create a `c:\temp` folder.
113
108
@@ -5479,20 +5474,18 @@ The following example moves a file.
5479
5474
<param name="sourceFileName">The name of a file that replaces the file specified by <paramref name="destinationFileName" />.</param>
5480
5475
<param name="destinationFileName">The name of the file being replaced.</param>
5481
5476
<param name="destinationBackupFileName">The name of the backup file.</param>
5482
-
<summary>Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file.</summary>
5477
+
<summary>Replaces the contents of a specified file with the contents of another file, deleting the original file and creating a backup of the replaced file.</summary>
5483
5478
<remarks>
5484
5479
<format type="text/markdown"><![CDATA[
5485
5480
5486
5481
## Remarks
5487
5482
The <xref:System.IO.File.Replace%2A> method replaces the contents of a specified file with the contents of another file. It also creates a backup of the file that was replaced.
5488
5483
5489
-
If the `sourceFileName` and `destinationFileName` are on different volumes, this method will raise an exception. If the `destinationBackupFileName` is on a different volume from the source file, the backup file will be deleted.
5490
-
5491
-
Pass `null` to the `destinationBackupFileName` parameter if you do not want to create a backup of the file being replaced.
5492
-
5493
-
If the `destinationBackupFileName` already exists it will be replaced with the contents of the `destinationFileName` file.
5484
+
If the `sourceFileName` and `destinationFileName` are on different volumes, this method raises an exception. If the `destinationBackupFileName` is on a different volume from the source file, the backup file will be deleted.
5494
5485
5486
+
Pass `null` to the `destinationBackupFileName` parameter if you don't want to create a backup of the file being replaced.
5495
5487
5488
+
If the `destinationBackupFileName` already exists, it's replaced with the contents of the `destinationFileName` file.
5496
5489
5497
5490
## Examples
5498
5491
The following code example uses the <xref:System.IO.File.Replace%2A> method to replace a file with another file and create a backup of the replaced file.
@@ -5504,18 +5497,10 @@ The following example moves a file.
5504
5497
5505
5498
]]></format>
5506
5499
</remarks>
5507
-
<exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> parameter was not of a legal form.
5508
-
5509
-
-or-
5510
-
5511
-
The path described by the <paramref name="destinationBackupFileName" /> parameter was not of a legal form.</exception>
5500
+
<exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> or <paramref name="destinationBackupFileName" /> parameter is not of a legal form.</exception>
5512
5501
<exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is <see langword="null" />.</exception>
5513
5502
<exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified.</exception>
5514
-
<exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.
5515
-
5516
-
-or-
5517
-
5518
-
The file described by the <paramref name="destinationBackupFileName" /> parameter could not be found.</exception>
5503
+
<exception cref="T:System.IO.FileNotFoundException">The file described by <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> parameter could not be found.</exception>
5519
5504
<exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.
5520
5505
5521
5506
-or-
@@ -5603,20 +5588,18 @@ The caller does not have the required permission.
5603
5588
<param name="destinationBackupFileName">The name of the backup file.</param>
5604
5589
<param name="ignoreMetadataErrors">
5605
5590
<see langword="true" /> to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, <see langword="false" />.</param>
5606
-
<summary>Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors.</summary>
5591
+
<summary>Replaces the contents of a specified file with the contents of another file, deleting the original file and creating a backup of the replaced file, and optionally ignores merge errors.</summary>
5607
5592
<remarks>
5608
5593
<format type="text/markdown"><![CDATA[
5609
5594
5610
5595
## Remarks
5611
5596
The <xref:System.IO.File.Replace%2A> method replaces the contents of a specified file with the contents of another file. It also creates a backup of the file that was replaced.
5612
5597
5613
-
If the `sourceFileName` and `destinationFileName` are on different volumes, this method will raise an exception. If the `destinationBackupFileName` is on a different volume from the source file, the backup file will be deleted.
5614
-
5615
-
Pass `null` to the `destinationBackupFileName` parameter if you do not want to create a backup of the file being replaced.
5616
-
5617
-
If the `destinationBackupFileName` already exists it will be replaced with the contents of the `destinationFileName` file.
5598
+
If the `sourceFileName` and `destinationFileName` are on different volumes, this method raises an exception. If the `destinationBackupFileName` is on a different volume from the source file, the backup file will be deleted.
5618
5599
5600
+
Pass `null` to the `destinationBackupFileName` parameter if you don't want to create a backup of the file being replaced.
5619
5601
5602
+
If the `destinationBackupFileName` already exists, it's replaced with the contents of the `destinationFileName` file.
5620
5603
5621
5604
## Examples
5622
5605
The following code example uses the <xref:System.IO.File.Replace%2A> method to replace a file with another file and create a backup of the replaced file.
@@ -5628,23 +5611,15 @@ The caller does not have the required permission.
5628
5611
5629
5612
]]></format>
5630
5613
</remarks>
5631
-
<exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> parameter was not of a legal form.
5632
-
5633
-
-or-
5634
-
5635
-
The path described by the <paramref name="destinationBackupFileName" /> parameter was not of a legal form.</exception>
5614
+
<exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> or <paramref name="destinationBackupFileName" /> parameter is not of a legal form.</exception>
5636
5615
<exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is <see langword="null" />.</exception>
5637
5616
<exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified.</exception>
5638
-
<exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.
5639
-
5640
-
-or-
5641
-
5642
-
The file described by the <paramref name="destinationBackupFileName" /> parameter could not be found.</exception>
5617
+
<exception cref="T:System.IO.FileNotFoundException">The file described by <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> parameter could not be found.</exception>
5643
5618
<exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.
5644
5619
5645
5620
-or-
5646
5621
5647
-
The <paramref name="sourceFileName" /> and <paramref name="destinationFileName" /> parameters specify the same file.</exception>
5622
+
<paramref name="sourceFileName" /> and <paramref name="destinationFileName" /> specify the same file.</exception>
5648
5623
<exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. </exception>
5649
5624
<exception cref="T:System.UnauthorizedAccessException">The <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> parameter specifies a file that is read-only.
5650
5625
@@ -5701,13 +5676,13 @@ The caller does not have the required permission.
5701
5676
<param name="returnFinalTarget">
5702
5677
<see langword="true" /> to follow links to the final target; <see langword="false" /> to return the immediate next link.</param>
5703
5678
<summary>Gets the target of the specified file link.</summary>
5704
-
<returns>A <see cref="T:System.IO.FileInfo" /> instance if <paramref name="linkPath" /> exists, independently if the target exists or not. <see langword="null" /> if <paramref name="linkPath" /> is not a link.</returns>
5679
+
<returns>A <see cref="T:System.IO.FileInfo" /> instance if <paramref name="linkPath" /> exists, independently of whether the target exists or not. <see langword="null" /> if <paramref name="linkPath" /> is not a link.</returns>
5705
5680
<remarks>
5706
5681
<format type="text/markdown"><![CDATA[
5707
5682
5708
5683
## Remarks
5709
5684
5710
-
When `returnFinalTarget` is `true`, the maximum number of symbolic links that are followed are 40 on Unix and 63 on Windows.
5685
+
When `returnFinalTarget` is `true`, the maximum number of symbolic links that are followed is 40 on Unix and 63 on Windows.
5711
5686
5712
5687
Symbolic links and junctions are the types of links this API can resolve.
5713
5688
@@ -6114,8 +6089,7 @@ It is not possible to change the compression status of a <xref:System.IO.File> o
6114
6089
</Parameters>
6115
6090
<Docs>
6116
6091
<param name="fileHandle">A <see cref="T:Microsoft.Win32.SafeHandles.SafeFileHandle" /> to the file or directory for which to set the creation date and time information.</param>
6117
-
<param name="creationTimeUtc">A <see cref="T:System.DateTime" /> containing the value to set for the creation date and time of <paramref name="fileHandle" />.
6118
-
This value is expressed in UTC time.</param>
6092
+
<param name="creationTimeUtc">The value to set for the creation date and time of <paramref name="fileHandle" />. This value is expressed in UTC time.</param>
6119
6093
<summary>Sets the date and time, in Coordinated Universal Time (UTC), that the file or directory was created.</summary>
6120
6094
<remarks>To be added.</remarks>
6121
6095
<exception cref="T:System.ArgumentNullException">
@@ -6177,7 +6151,7 @@ It is not possible to change the compression status of a <xref:System.IO.File> o
6177
6151
</Parameters>
6178
6152
<Docs>
6179
6153
<param name="path">The file for which to set the creation date and time information.</param>
6180
-
<param name="creationTimeUtc">A <see cref="T:System.DateTime" /> containing the value to set for the creation date and time of <paramref name="path" />. This value is expressed in UTC time.</param>
6154
+
<param name="creationTimeUtc">The value to set for the creation date and time of <paramref name="path" />. This value is expressed in UTC time.</param>
6181
6155
<summary>Sets the date and time, in Coordinated Universal Time (UTC), that the file was created.</summary>
6182
6156
<remarks>
6183
6157
<format type="text/markdown"><![CDATA[
@@ -6198,7 +6172,7 @@ It is not possible to change the compression status of a <xref:System.IO.File> o
6198
6172
<exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. </exception>
6199
6173
<exception cref="T:System.IO.IOException">An I/O error occurred while performing the operation.</exception>
0 commit comments