GetShortPathName (kernel32)
Last changed: -74.13.52.113

.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern uint GetShortPathName(string lpszLongPath,
   [Out] StringBuilder lpszShortPath, uint cchBuffer);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

/// <summary>
/// The ToLongPathNameToShortPathName function retrieves the short path form of a specified long input path
/// </summary>
/// <param name="longName">The long name path</param>
/// <returns>A short name path string</returns>
public static string ToShortPathName(string longName)
{
    StringBuilder shortNameBuffer = new StringBuilder(256);
    int bufferSize = shortNameBuffer.Capacity;

    int result = GetShortPathName(longName, shortNameBuffer, bufferSize);

    return shortNameBuffer.ToString();
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation