Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectoryInfo.MoveTo mistakenly prevents renaming directories to case variations of themselves on Windows, macOS #63287

Closed
Tracked by #64596
mklement0 opened this issue Jan 3, 2022 · 1 comment · Fixed by #63675
Assignees
Milestone

Comments

@mklement0
Copy link

Description

Note: The original bug report, #30479, covered both DirectoryInfo.MoveTo() and Directory.Move(), but the PR that was meant to fix the problem fixed Directory.Move() only.

See the linked report for conceptual background information.

Reproduction Steps

You can paste following snippet directly into a dotnet-script REPL and press Enter.

using System.IO;

Environment.CurrentDirectory = Path.GetTempPath();

var di = Directory.CreateDirectory("foo");

// This should succeed even on macOS and Windows, but throws an exception.
di.MoveTo("FOO");

Expected behavior

Renaming should succeed, on all supported platforms.

Actual behavior

On Windows and macOS, the following exception is thrown:

System.IO.IOException: Source and destination path must be different.

Regression?

No response

Known Workarounds

Use the static Directory.Move() method instead.

Configuration

.NET 6.0.0-rtm.21522.10

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.IO untriaged New issue has not been triaged by the area owner labels Jan 3, 2022
@ghost
Copy link

ghost commented Jan 3, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Note: The original bug report, #30479, covered both DirectoryInfo.MoveTo() and Directory.Move(), but the PR that was meant to fix the problem fixed Directory.Move() only.

See the linked report for conceptual background information.

Reproduction Steps

You can paste following snippet directly into a dotnet-script REPL and press Enter.

using System.IO;

Environment.CurrentDirectory = Path.GetTempPath();

var di = Directory.CreateDirectory("foo");

// This should succeed even on macOS and Windows, but throws an exception.
di.MoveTo("FOO");

Expected behavior

Renaming should succeed, on all supported platforms.

Actual behavior

On Windows and macOS, the following exception is thrown:

System.IO.IOException: Source and destination path must be different.

Regression?

No response

Known Workarounds

Use the static Directory.Move() method instead.

Configuration

.NET 6.0.0-rtm.21522.10

Other information

No response

Author: mklement0
Assignees: -
Labels:

area-System.IO, untriaged

Milestone: -

@adamsitnik adamsitnik self-assigned this Jan 12, 2022
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Jan 12, 2022
@adamsitnik adamsitnik added this to the 7.0.0 milestone Jan 12, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 12, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 8, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants