Skip to content

Commit 2f1cd50

Browse files
gukoffKonstantin Gukovadamsitnik
authored
Better document File.Move across disk volumes. (dotnet#5249)
* Better cover File.Move across disk volumes. Currently the documentation claims that IOException is only thrown if `destFileName` exists. This is not true - moving across disk volumes involves copying and opens various IOException possibilities, e.g. "no space left on device". * Apply suggestions from code review Co-authored-by: Konstantin Gukov <[email protected]> Co-authored-by: Adam Sitnik <[email protected]>
1 parent b571b2c commit 2f1cd50

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

xml/System.IO/File.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,8 @@ Note that if you attempt to replace a file by moving a file of the same name int
25182518
25192519
The `sourceFileName` and `destFileName` arguments can include relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see <xref:System.IO.Directory.GetCurrentDirectory%2A>.
25202520
2521+
Moving the file across disk volumes is equivalent to copying the file and deleting it from the source if the copying was successful.
2522+
25212523
If you try to move a file across disk volumes and that file is in use, the file is copied to the destination, but it is not deleted from the source.
25222524
25232525
For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks).
@@ -2534,6 +2536,10 @@ The following example moves a file.
25342536
</remarks>
25352537
<exception cref="T:System.IO.IOException">
25362538
<paramref name="destFileName" /> already exists.
2539+
2540+
-or-
2541+
2542+
An I/O error has occurred, e.g. while copying the file across disk volumes.
25372543
</exception>
25382544
<exception cref="T:System.IO.FileNotFoundException">
25392545
<paramref name="sourceFileName" /> was not found.
@@ -2595,6 +2601,8 @@ This method works across disk volumes, and it does not throw an exception if the
25952601
25962602
The `sourceFileName` and `destFileName` arguments can include relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see <xref:System.IO.Directory.GetCurrentDirectory%2A>.
25972603
2604+
Moving the file across disk volumes is equivalent to copying the file and deleting it from the source if the copying was successful.
2605+
25982606
If you try to move a file across disk volumes and that file is in use, the file is copied to the destination, but it is not deleted from the source.
25992607
26002608
For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks).
@@ -2611,6 +2619,10 @@ The following example moves a file.
26112619
</remarks>
26122620
<exception cref="T:System.IO.IOException">
26132621
<paramref name="destFileName" /> already exists and <paramref name="overwrite" /> is <see langword="false" />.
2622+
2623+
-or-
2624+
2625+
An I/O error has occurred, e.g. while copying the file across disk volumes.
26142626
</exception>
26152627
<exception cref="T:System.IO.FileNotFoundException">
26162628
<paramref name="sourceFileName" /> was not found.</exception>

0 commit comments

Comments
 (0)