当前位置: 代码迷 >> .NET Framework >> C#大神帮忙啊解决思路
  详细解决方案

C#大神帮忙啊解决思路

热度:113   发布时间:2016-05-01 23:35:40.0
C#大神帮忙啊。
本帖最后由 codejava 于 2014-05-26 19:17:48 编辑
[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?
  相关解决方案