UweKeim / ZetaLongPaths

A .NET library to access files and directories with more than 260 characters length.

Home Page:https://nuget.org/packages/ZetaLongPaths

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZlpFileInfo.Length throws PathTooLongException

hugollm opened this issue · comments

Apparently, ZlpFileInfo makes use of System.IO to return file Length, throwing the very exception it is supposed to avoid.

The error could be reproduced with a code similar to:

string path = "C:\\Users\\cliente\\Desktop\\DRIVES~2\\mdzip\\PASTAC~1\\SUBPAS~1\\PASTAC~1\\SUBPAS~1\\SUBDAS~1\\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.txt";
var info = new ZlpFileInfo(path);
info.Length...

The exception traceback were as follows:

System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

at System.IO.PathHelper.Append(Char value)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
at System.IO.FileInfo..ctor(String fileName)
at ZetaLongPaths.ZlpIOHelper.GetFileLength(String filePath) in c:\P\ZetaLongPaths\Source\Runtime\ZlpIOHelper.cs:line 1277
at ZetaLongPaths.ZlpFileInfo.get_Length() in c:\P\ZetaLongPaths\Source\Runtime\ZlpFileInfo.cs:line 171
at DriveShare.Drive.FileDownloader.DownloadIscomplete(DriveFile driveFile, String targetPath) in c:\projetos\driveshareclient\DriveShare\DriveShare\Drive\FileDownloader.cs:line 49
at DriveShare.Drive.FileDownloader.DownloadFile(IndexedFile file, String targetPath) in c:\projetos\driveshareclient\DriveShare\DriveShare\Drive\FileDownloader.cs:line 35
at DriveShare.Drive.Storage.DownloadFile(IndexedFile file, String targetPath) in c:\projetos\driveshareclient\DriveShare\DriveShare\Drive\Storage.cs:line 40
at DriveShare.Tasks.DownloadTask.Execute() in c:\projetos\driveshareclient\DriveShare\DriveShare\Tasks\DownloadTask.cs:line 20
at DriveShare.Workers.TaskWorker.ExecuteTask(Task task) in c:\projetos\driveshareclient\DriveShare\DriveShare\Workers\TaskWorker.cs:line 64
at DriveShare.Workers.TaskWorker.TryExecuteTask(Task task) in c:\projetos\driveshareclient\DriveShare\DriveShare\Workers\TaskWorker.cs:line 35

Thanks, I'll take a look.

Worked like a charm! Thank you so much for the awesome work (:

Thank you 😀