得到短文件名的长文件名

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

最近在网上看到,系统传递的文件路径有时是DOS形式的短文件名,有人给出了C++的解决方法。下面我列出了C#的方法:

using System.IO;

private static string GetLongPathName(string Short)

{

DirectoryInfo pdi = new DirectoryInfo(Short);

string rt = "";

while(pdi.Parent != null)

{

string [] tmp = Directory.GetDirectories(pdi.Parent.FullName,pdi.Name);

DirectoryInfo di = new DirectoryInfo(tmp[0]);

rt = Path.Combine(di.Name,rt);

pdi = pdi.Parent;

}

rt = Path.Combine(pdi.Root.Name,rt);

return rt;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航