peteraritchie / LongPath

drop-in library to support long paths in .NET
GNU Lesser General Public License v3.0
112 stars 43 forks source link

File.Copy throws an IOException that does not contain the filename if the file exists #47

Open herebebeasties opened 7 years ago

herebebeasties commented 7 years ago
System.IO.File.Copy(@"e:\foo", @"e:\bar", false);

...gives "The file 'e:\bar' already exists." in the thrown IOException's Message, whereas:

Pri.LongPath.File.Copy(@"e:\foo", @"e:\bar", false);

...gives only "The file exists." I think this is because File.cs:135 is using throw Common.GetExceptionFromLastWin32Error() instead of Common.ThrowIOError(errorCode, fullPath).

Maybe GetExceptionFromLastWin32Error() could do with taking an optional fullPath argument? It looks like perhaps ThrowIOError and GetExceptionFromLastWin32Error ought to be unified, given what they do - not sure on your thoughts on that.

Thanks for the brilliantly useful library, by the way! :-)