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

File.Copy fails with DirectoryNotFoundException on long path #489

Closed CyberSinh closed 5 years ago

CyberSinh commented 5 years ago

Hi,

I use AlphaFS 2.2.5 (latest NuGet package).

After using the following line of code to copy long path: File.Copy(source, destination, options, true, CopyMoveProgressCallback, null, PathFormat.FullPath);

I got this error:

System.IO.DirectoryNotFoundException
  HResult=0x80070003
  Message=C:\Users\xxxxxxx xxxxxxxx\Downloads\iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\MetatoggerOffice2016ColorfulSE\.td\Sources\obj.Temp\MetatoggerOffice2016ColorfulSE\DocumentViewer\MetatoggerOffice2016ColorfulSE\DocumentViewerBarItems.xaml
  Source=AlphaFS
  Arborescence des appels de procédure :
   at Alphaleonis.Win32.Filesystem.Directory.ExistsDriveOrFolderOrFile(KernelTransaction transaction, String path, Boolean isFolder, Int32 lastError, Boolean throwIfDriveNotExists, Boolean throwIfFolderOrFileNotExists) in C:\Users\jjangli\Documents\GitHub\AlphaFS\AlphaFS\Filesystem\Directory Class\Directory.ExistsDrive.cs:line 86
  1. As you can see, the copy fails with DirectoryNotFoundException. The issue seems to be related to long path because if I change the destination from C:\Users\xxxxxxx xxxxxxxx\Downloads\iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\MetatoggerOffice2016ColorfulSE\.td\Sources\obj.Temp\MetatoggerOffice2016ColorfulSE\DocumentViewer\MetatoggerOffice2016ColorfulSE\DocumentViewerBarItems.xaml to C:\Users\xxxxxxx xxxxxxxx\Downloads\i\MetatoggerOffice2016ColorfulSE\.td\Sources\obj.Temp\MetatoggerOffice2016ColorfulSE\DocumentViewer\MetatoggerOffice2016ColorfulSE\DocumentViewerBarItems.xaml, the copy works as expected. I expected to be immune to PathTooLong errors with AlphaFS. But maybe I missed something?

  2. As you can also see, the error message that is returned by AlphaFS is particularly abstruse since only the path to the file is returned without specifying the nature of the problem. Without debugger attached, difficult to determine the real underlying problem.

Thanks you for your help.

Regards,

Yomodo commented 5 years ago

The quick fix for this is to remove the PathFormat.FullPath

Yomodo commented 5 years ago

Thank for reporting, should be fixed now.

CyberSinh commented 5 years ago

Thank you Yomodo!