[System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern int GetShortPathName(
string Path,
System.Text.StringBuilder ShortPath,
int ShortPathLength
);
public static string GetShortPathName_CreateDestroy(string Path) {
bool fCreate = !System.IO.File.Exists(Path);
if (fCreate)
System.IO.File.Create(Path).Dispose();
string shortPath = GetShortPathName(Path);
if (fCreate)
System.IO.File.Delete(Path);
return shortPath;
}
public static string GetShortPathName(string Path) {
System.Text.StringBuilder shortPath = new System.Text.StringBuilder(255);
GetShortPathName(Path, shortPath, shortPath.Capacity);
return shortPath.ToString();
}