If File.Move is used on macOS to rename a file that differs only by case, it fails:
class Program
{
static void Main(string[] args)
{
File.WriteAllText("foo.txt", "test");
File.Move("foo.txt", "Foo.txt"); //this throws
}
}
This results in the following exception:
Unhandled Exception: System.IO.IOException: The file '/Users/Brandon/Code/repro2/Foo.txt' already exists.
at System.IO.UnixFileSystem.MoveFile(String sourceFullPath, String destFullPath)
at System.IO.File.Move(String sourceFileName, String destFileName)
at repro2.Program.Main(String[] args) in /Users/Brandon/Code/repro2/Program.cs:line 11
This same program does not throw when run on Windows or linux, and instead results in the renamed Foo.txt on disk.
I would expect this to behave consistently across all platforms. Using mv foo.txt Foo.txt on macOS renames the file correctly, so I would expect the same thing to be possible via File.Move.
dotnet --info
.NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/1.0.1
If
File.Moveis used on macOS to rename a file that differs only by case, it fails:This results in the following exception:
This same program does not throw when run on Windows or linux, and instead results in the renamed
Foo.txton disk.I would expect this to behave consistently across all platforms. Using
mv foo.txt Foo.txton macOS renames the file correctly, so I would expect the same thing to be possible viaFile.Move.