Beispiel #1
0
        public static string GetLongPath(string path)
        {
            path = ZlpIOHelper.CheckAddLongPathPrefix(path);

            // --
            // Determine length.

            var sb = new StringBuilder();

            var realLength = PInvokeHelper.GetLongPathName(path, sb, 0);

            // --

            sb.Length  = (int)realLength;
            realLength = PInvokeHelper.GetLongPathName(path, sb, (uint)sb.Length);

            if (realLength <= 0)
            {
                var lastWin32Error = Marshal.GetLastWin32Error();
                throw new Win32Exception(
                          lastWin32Error,
                          $"Error {lastWin32Error} getting long path for '{path}': {ZlpIOHelper.CheckAddDotEnd(new Win32Exception(lastWin32Error).Message)}");
            }
            else
            {
                return(sb.ToString());
            }
        }