AlphaFS icon indicating copy to clipboard operation
AlphaFS copied to clipboard

(FileInfo|DirectoryInfo).Copy() mutates the instance's path

Open mlaily opened this issue 4 years ago • 0 comments

FileInfo x = new FileInfo("a");
x.Copy("b"); // <-- returns a new FileInfo with the path "b", and also mutate x so its path is now "b"
x.Delete(); // Boom you lost your copy ("b"), but "a" is still there!

It seems intended but while I can see how this is the right behaviour for Move(), I can't follow the reasoning for Copy(). Besides, System.IO.*Info.Copy() don't mutate their instances (There is a discrepancy there between System.IO and AlphaFS).

mlaily avatar Jun 29 '21 15:06 mlaily