[DllImport("kernel32.dll", EntryPoint = "GetShortPathName",CharSet=CharSet.Auto)]
public static extern int GetShortPathName(string lpszLongPath, string lpszShortPath, int cchBuffer);
string sbShort="";
string str = "C:\Program Files (x86)\Common Files\VMware\USB";
result = GetShortPathName(str, sbShort, 300); //
//sbShort为什么没有值呢,result返回成功了啊。大家帮帮忙。
------解决方案--------------------
第二个参数需要传StringBuilder
------解决方案--------------------
把public static extern int GetShortPathName(string lpszLongPath, StringBuilderlpszShortPath, int cchBuffer);
//第二个参数改为StringBuilder即可
//
------解决方案--------------------
StringBuilder或者ref sbShort试试
------解决方案--------------------
StringBuilder,第二个参数
------解决方案--------------------
难道.net自带的Path类还不够你用,这么点分析路径的小功能还要求助于外部dll?