[C#] 8.3 Name eines Verzeichnis....
-
Servus,
ich fummeln nun schon wieder ca. 1 Stunde hier an einem Verzeichnisnamen herum. Ich würde gerne in einer C# App einen Verzeichnisnamen in 8.3 Konvetierung geliefert bekommen.
Bsp.:
C:\Softwareblubb\ -> C:\Softwa~1\Ich komme doch zum Teufel nicht dahinter wie ich das anstelle.....
Vielleicht kann mir jemand weiterhelfen.
Schankeön im Vorhaus
Hellsgore
-
Es gibt da 'ne API-Funktion dafür
[DllImport("kernel32.dll", SetLastError=true)] static extern int GetShortPathName ( string lpszLongPath, string lpszShortPath, int cchBuffer)
Parameter:
lpszLongPath
The complete long path and filename to convert.lpszShortPath
Receives the 8.3 form of the filename, terminated by a null character. This string must already be sufficiently large to receive the 8.3 filename.cchBuffer
The length of the string passed as lpszShortPath.
-
Servus,
japp, schankedön. Habe ich auch gerade entdeckt.
Für ungeduldige Tüfftler:
[System.Runtime.InteropServices.DllImport("kernel32.dll")] private static extern int GetShortPathName (string lpszLongPath, StringBuilder lpszShortPath, int cchBuffer); StringBuilder shortPath = new StringBuilder(100); GetShortPathName(@"C:\HierdeinLangerPfad\", shortPath, shortPath.Capacity); string strReturn = shortPath.ToString();
Dankeschön nochmals...
*winke*
Hellsgore