Long Pathes
March 25th, 2008
Just a short snipped I’d like to not forget about.
The maximal possible pathlength on Windows is, as you probably know, 255 chars. For that reason you can use the following:
Convert short path to long:
String s = Short2Long(@"D:\MYTEMP~1\RESOUR~1\sql.txt"); public static String Short2Long(String sShortPath) { StringBuilder sLongPath = new StringBuilder(255); GetLongPathName(sShortPath, sLongPath, sLongPath.Capacity); return sLongPath.ToString(); }
Vice versa:
String s = Long2Short(@"D:\My Temp\ResourseProvider\sql.txt"); public static String Long2Short(String sLongPath) { StringBuilder sShortPath = new StringBuilder(255); GetShortPathName(sLongPath, sShortPath, sShortPath.Capacity); return sShortPath.ToString(); }
Hope it might help you somewhere along the way ![]()






Your fonts are very small — hard to read.
Comment by Andreas Brekken — September 16, 2008 @ 3:13 pm