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

Incorrect handling of \\?\UNC\

kmarivoe opened this issue · comments

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.

Thanks, I'll take a look.

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
#6 (comment).

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