UweKeim / ZetaLongPaths

A .NET library to access files and directories with more than 260 characters length.
https://nuget.org/packages/ZetaLongPaths
MIT License
142 stars 28 forks source link

Incorrect handling of \\?\UNC\ #6

Closed kmarivoe closed 9 years ago

kmarivoe commented 9 years ago

Hi,

I'm trying to use 'ZlpIOHelper.CreateDirectory' on a path with a share name, for example: "\192.168.11.150\Share\data"

the long path representation is: "\?\UNC\192.168.11.150\Share\data"

When I try o run create directory on this, Zlp doesn't detect that this is a share path: SplitFolderPath removes the '\?\UNC\" prefix, which leaves '192.168.11.150\Share\data...", and this is a normal path. As a result I get a directory in the working dir of my application, rooted at '192.168.11.150'.

I'm using ZetaLongPaths 1.0.0.6.

UweKeim commented 9 years ago

Thanks, I'll take a look.

kmarivoe commented 9 years ago

The fix is quite simple:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<, public static string ForceRemoveLongPathPrefix(string path) { if (string.IsNullOrEmpty(path) || !path.StartsWith(@"\?\")) { return path; } else if (path.StartsWith(@"\?\UNC\", StringComparison.InvariantCultureIgnoreCase)) { return @"\" + path.Substring(@"\?\UNC\".Length); } else { return path.Substring(@"\?\".Length); } } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Regards, Kim

On Mon, Dec 15, 2014 at 2:52 PM, Uwe Keim notifications@github.com wrote:

Thanks, I'll take a look.

— Reply to this email directly or view it on GitHub https://github.com/UweKeim/ZetaLongPaths/issues/6#issuecomment-66996405.

UweKeim commented 9 years ago

Thanks, Kim, I've just commited the fixes (I kept the version number for now).