Create WinBase.File.cs (#213)

MAX_PATH is not a hard limit on the maximum length of a file path. Using Windows 10, I have a file path that is ~378 chars long, and an exception is thrown in the local method AddCap because the code attempts to increase the size of the StringBuilder beyond the 261 chars that was specified in the constructor. This change just removes the hard upper limit cap on that length.
pull/217/head
Matt Haynie 2021-02-28 17:57:02 -08:00 committed by GitHub
parent d7eeb1ca06
commit 63f7a1d201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -3177,7 +3177,7 @@ namespace Vanara.PInvoke
/// <returns>List of strings returned by <paramref name="first"/> and <paramref name="next"/> methods.</returns>
private static IEnumerable<string> EnumFindMethods<THandle>(FindFirstDelegate<THandle> first, FindNextDelegate<THandle> next, uint strSz = MAX_PATH + 1, uint done = Win32Error.ERROR_HANDLE_EOF) where THandle : SafeHandle
{
var sb = new StringBuilder((int)strSz, (int)strSz);
var sb = new StringBuilder((int)strSz);
THandle h;
while ((h = first(sb, ref strSz)).IsInvalid)
{
@ -5153,4 +5153,4 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => FindVolumeMountPointClose(handle);
}
}
}
}