There is no direct support in the framework to do this. You have to use the GetShortPathName function using PInvoke.
This is how the signature for this function looks like:
[DllImport(''kernel32.dll'', SetLastError=true, CharSet=CharSet.Auto)]
public static extern int GetShortPathName(string longPath, [MarshalAs(UnmanagedType.LPTStr)]StringBuilder ShortPath, [MarshalAs(UnmanagedType.U4)]int bufferSize);
Download C# Sample GetShortPathName.zip
Download VB.NET sample GetShortPathName_VB.zip
Share with