Métriques du dépôt
- Stars
- (17 886 stars)
- Métriques de merge PR
- (Merge moyen 12j 11h) (661 PRs mergées en 30 j)
Description
Similarly to what I did in https://github.com/dotnet/runtime/pull/63675 for Directory.Move there is most likely no need to perform a check whether source file exists in https://github.com/dotnet/runtime/blob/71393d07bc2f8a388dd2e06726757eaf11e3307c/src/libraries/System.Private.CoreLib/src/System/IO/File.cs#L417
The native sys-call that is called by FileSystem.MoveFile is most likely going to fail in such situations. We should just handle the FileSystem.MoveFile failure and map it to the same (existing) exception on both Windows and Unix.
The following condition can most likely avoid the check as well:
(we could check if the source file is the same file/drive as destination only after we verify that destination exists. In cases where destination does not exists there is no need of doing that)
While working on this it would be nice to unify File.Move and FileInfo.MoveTo and fix https://github.com/dotnet/runtime/issues/35122
The contributor who is willing to work on this issue needs to contribute File.Move benchmarks to the https://github.com/dotnet/performance repository. The File benchmarks can be found here. Here you can find docs that explain how to run the benchmarks against local build of dotnet/runtime.