Skip to content

Commit

Permalink
Create WinBase.File.cs (#213)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PazerOP authored Mar 1, 2021
1 parent d7eeb1c commit 63f7a1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PInvoke/Kernel32/WinBase.File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3177,7 +3177,7 @@ public static unsafe extern bool ReadDirectoryChangesExW(HFILE hDirectory, IntPt
/// <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)
{
Expand Down Expand Up @@ -5153,4 +5153,4 @@ private SafeVolumeMountPointHandle() : base()
protected override bool InternalReleaseHandle() => FindVolumeMountPointClose(handle);
}
}
}
}

0 comments on commit 63f7a1d

Please sign in to comment.