Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions xml/System.IO/Directory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3468,22 +3468,25 @@ Directory::CreateDirectory("Public\\Html");
Trailing spaces are removed from the end of the path parameters before moving the directory.

For a list of common I/O tasks, see [Common I/O Tasks](~/docs/standard/io/common-i-o-tasks.md).



> [!NOTE]
> Starting with .NET Core 3.0, the `Move` method throws an <xref:System.IO.IOException> in all platforms when the `destDirName` already exists. In .NET Core 2.2 and previous versions, the exception was only thrown on Windows, and other platforms could either fail or overwrite the `destDirName`. See [C++ rename](https://linux.die.net/man/2/rename).


## Examples
The following example demonstrates how to move a directory and all its files to a new directory. The original directory no longer exists after it has been moved.

[!code-csharp[System.IO.Directory#14](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.IO.Directory/CS/class6.cs#14)]
[!code-vb[System.IO.Directory#14](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Directory/VB/class6.vb#14)]

]]></format>
</remarks>
<exception cref="T:System.IO.IOException">An attempt was made to move a directory to a different volume.
<exception cref="T:System.IO.IOException">An attempt was made to move a directory to a different volume.

-or-

<paramref name="destDirName" /> already exists.
<paramref name="destDirName" /> already exists. See the Note in the Remarks section.

-or-

Expand Down Expand Up @@ -4143,4 +4146,4 @@ Directory::CreateDirectory("Public\\Html");
</Docs>
</Member>
</Members>
</Type>
</Type>