[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern int GetShortPathName(
string lpszLongPath,
[Out] StringBuilder lpszShortPath,
int cchBuffer);
Declare Auto Function GetShortPathName Lib "kernel32.dll" _
(ByVal lpszLongPath As String, _
ByVal lpszShortPath As StringBuilder, _
ByVal cchBuffer As Integer) As Integer
None.
None.
Please add some!
/// <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();
int size = GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity);
if(size >= shortNameBuffer.Capacity)
{
shortNameBuffer.Capacity = size + 1;
GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity);
}
return shortNameBuffer.ToString();
}
Do you know one? Please contribute it!