Skip to content

Commit 3f70f78

Browse files
authored
clean up File.Replace docs (#10137)
1 parent 0371253 commit 3f70f78

File tree

2 files changed

+34
-64
lines changed

2 files changed

+34
-64
lines changed

xml/System.IO/File.xml

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777

7878
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>.
7979

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.
8181

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.
8383

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

@@ -97,17 +97,12 @@
9797
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:
9898

9999
- `"c:\\\MyDir\\\MyFile.txt"` in C#, or `"c:\MyDir\MyFile.txt"` in Visual Basic.
100-
101100
- `"c:\\\MyDir"` in C#, or `"c:\MyDir"` in Visual Basic.
102-
103101
- `"MyDir\\\MySubdir"` in C#, or `"MyDir\MySubDir"` in Visual Basic.
104-
105102
- `"\\\\\\\MyServer\\\MyShare"` in C#, or `"\\\MyServer\MyShare"` in Visual Basic.
106103

107104
For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks).
108105

109-
110-
111106
## Examples
112107
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.
113108

@@ -5479,20 +5474,18 @@ The following example moves a file.
54795474
<param name="sourceFileName">The name of a file that replaces the file specified by <paramref name="destinationFileName" />.</param>
54805475
<param name="destinationFileName">The name of the file being replaced.</param>
54815476
<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>
54835478
<remarks>
54845479
<format type="text/markdown"><![CDATA[
54855480

54865481
## Remarks
54875482
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.
54885483

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.
54945485

5486+
Pass `null` to the `destinationBackupFileName` parameter if you don't want to create a backup of the file being replaced.
54955487

5488+
If the `destinationBackupFileName` already exists, it's replaced with the contents of the `destinationFileName` file.
54965489

54975490
## Examples
54985491
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.
55045497

55055498
]]></format>
55065499
</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>
55125501
<exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is <see langword="null" />.</exception>
55135502
<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>
55195504
<exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.
55205505

55215506
-or-
@@ -5603,20 +5588,18 @@ The caller does not have the required permission.
56035588
<param name="destinationBackupFileName">The name of the backup file.</param>
56045589
<param name="ignoreMetadataErrors">
56055590
<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>
56075592
<remarks>
56085593
<format type="text/markdown"><![CDATA[
56095594

56105595
## Remarks
56115596
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.
56125597

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.
56185599

5600+
Pass `null` to the `destinationBackupFileName` parameter if you don't want to create a backup of the file being replaced.
56195601

5602+
If the `destinationBackupFileName` already exists, it's replaced with the contents of the `destinationFileName` file.
56205603

56215604
## Examples
56225605
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.
56285611

56295612
]]></format>
56305613
</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>
56365615
<exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is <see langword="null" />.</exception>
56375616
<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>
56435618
<exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.
56445619

56455620
-or-
56465621

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>
56485623
<exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. </exception>
56495624
<exception cref="T:System.UnauthorizedAccessException">The <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> parameter specifies a file that is read-only.
56505625

@@ -5701,13 +5676,13 @@ The caller does not have the required permission.
57015676
<param name="returnFinalTarget">
57025677
<see langword="true" /> to follow links to the final target; <see langword="false" /> to return the immediate next link.</param>
57035678
<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>
57055680
<remarks>
57065681
<format type="text/markdown"><![CDATA[
57075682

57085683
## Remarks
57095684

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.
57115686

57125687
Symbolic links and junctions are the types of links this API can resolve.
57135688

@@ -6114,8 +6089,7 @@ It is not possible to change the compression status of a <xref:System.IO.File> o
61146089
</Parameters>
61156090
<Docs>
61166091
<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>
61196093
<summary>Sets the date and time, in Coordinated Universal Time (UTC), that the file or directory was created.</summary>
61206094
<remarks>To be added.</remarks>
61216095
<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
61776151
</Parameters>
61786152
<Docs>
61796153
<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>
61816155
<summary>Sets the date and time, in Coordinated Universal Time (UTC), that the file was created.</summary>
61826156
<remarks>
61836157
<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
61986172
<exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. </exception>
61996173
<exception cref="T:System.IO.IOException">An I/O error occurred while performing the operation.</exception>
62006174
<exception cref="T:System.ArgumentOutOfRangeException">
6201-
<paramref name="creationTime" /> specifies a value outside the range of dates, times, or both permitted for this operation.</exception>
6175+
<paramref name="creationTimeUtc" /> specifies a value outside the range of dates, times, or both permitted for this operation.</exception>
62026176
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
62036177
<exception cref="T:System.NotSupportedException">
62046178
<paramref name="path" /> is in an invalid format.</exception>

0 commit comments

Comments
 (0)