public static string ToShortPathName(string longName)
{
StringBuilder shortNameBuffer = new StringBuilder(256);
int bufferSize = shortNameBuffer.Capacity;
int result = GetShortPathName(longName, shortNameBuffer, bufferSize);
return shortNameBuffer.ToString();
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path,[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,int shortPathLength);