标签:file box bubuko http pat static 函数 技术 ips
实现效果:

知识运用:
系统API函数GetShortPathName
[DllImport("Kernel32.dll")]
private static extern Int16 GetShortPathName(string IpszLongPath,StringBuilder IpszShortPath,Int16 cchBuffer);

实现代码:
[DllImport("Kernel32.dll")]
private static extern Int16 GetShortPathName(string IpszLongPath,StringBuilder IpszShortPath,Int16 cchBuffer);
private void button1_Click(object sender, EventArgs e)
{
if (OFDlog.ShowDialog() == DialogResult.OK)
{
textBox1.Text = OFDlog.FileName;
string longName = textBox1.Text;
StringBuilder shortName = new System.Text.StringBuilder(256);
GetShortPathName(longName,shortName,256);
string myInfo = "长文件名:" + longName;
myInfo += "\n" + "短文件名:" + shortName;
label2.Text = myInfo;
}
标签:file box bubuko http pat static 函数 技术 ips
原文地址:https://www.cnblogs.com/feiyucha/p/10223096.html