dotnet / dotnet/dotnet-api-docs

Directory.Move: Undocumented exception

Open
#5,315 0 comments 0 reactions 0 assignees View on GitHub
area-System.IO Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

Repro:

1. Create a directory `C:\temp\A`. Make sure that the directory `C:\temp\B` **does not exist.**
2. Execute `Directory.Move(@"C:\temp\A", @"C:\temp\B\C");`

Note that you get the following exception: `System.IO.DirectoryNotFoundException: Could not find a part of the path.`

However, the [documentation of Directory.Move](https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.move?view=netframework-4.8) states that a `DirectoryNotFoundException` is only thrown in the following case:

> The path specified by sourceDirName is invalid (for example, it is on an unmapped drive).

In this case, the path specified by sourceDirName is *not* invalid.

Suggested fix:

1. Find out under which circumstances `Directory.Move` can throw a `DirectoryNotFoundException` (in the example above, it's the fact that the parent of the path specified by `destDirName` does not exist, but there might be others as well).
2. Update the documentation to list all the cases.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.