C#调用Windows API GetShortPathName获取短文件名疑问
[DllImport("kernel32.dll",CharSet=CharSet.Auto)]publicstaticexternintGetShortPathName...
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
private void button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(255);
int length = GetShortPathName(@"C:\test.txt", sb, sb.Capacity);
string shortName = sb.ToString();
}
为什么length是0,,得到的shortName为""?如何才能正确获取段文件名? 展开
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
private void button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(255);
int length = GetShortPathName(@"C:\test.txt", sb, sb.Capacity);
string shortName = sb.ToString();
}
为什么length是0,,得到的shortName为""?如何才能正确获取段文件名? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询