alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
558 stars 99 forks source link

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

Open mlaily opened 3 years ago

mlaily commented 3 years ago
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).