public LongPath(string path) { Check.DoRequireArgumentNotNull(path, "path"); Check.DoCheckArgument(!string.IsNullOrEmpty(path), string.Empty, "path"); StringBuilder bld = new StringBuilder(path.Length + 5); uint size = WindowsNative.GetFullPathName(path, (uint)bld.Capacity, bld, IntPtr.Zero); if (size > bld.Capacity) { bld.Capacity = (int)size + 5; size = WindowsNative.GetFullPathName(path, size, bld, IntPtr.Zero); } Check.DoAssertLambda(size > 0, () => WindowsNative.GetLastErrorException("path")); Check.DoAssertLambda(size <= WindowsNative.MAX_LONG_PATH, () => new PathTooLongException()); bld.Insert(0, WindowsNative.LongPathPrefix); PathString = bld.ToString(); }