文件的长路径如何转换为短路径(dos格式)

简介:

using System.Runtime.InteropServices;

定义:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
[MarshalAs(UnmanagedType.LPTStr)]
string path,
[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength);

引用:
StringBuilder shortPath = new StringBuilder(80);
int result = GetShortPathName(
@"F:\1234567891.jpg", shortPath, shortPath.Capacity);
string s = shortPath.ToString();
MessageBox.Show(s.ToString());

结果:
F:\123456~1.jpg

转自csdn




本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2009/08/31/1557319.html,如需转载请自行联系原作者

 

相关文章
|
4月前
|
Linux 索引 关系型数据库
Linux 终端命令之文件目录操作,对比Dos相关命令
Linux 终端命令之文件目录操作,对比Dos相关命令
82 0
Linux 终端命令之文件目录操作,对比Dos相关命令
|
编译器 Windows
PE文件学习--Dos头部
PE文件学习--Dos头部
156 0
|
IDE 开发工具 C++
Python命令行解析:IDE内点击Run运行代码直接得出结果、基于TF flags(或argparse、sys.argv)在Dos内命令行(一条命令)调用代码文件得出结果
Python命令行解析:IDE内点击Run运行代码直接得出结果、基于TF flags(或argparse、sys.argv)在Dos内命令行(一条命令)调用代码文件得出结果