我想在自己程序里调用cmd的文件比较命令:fc
Process fileDiffProcess = Process.Start(this._exePath,argues);
但是,在参数argues内,我要用到的文件名称要有空格,但是空格又是两个文件名的区分符,
比如:this.exePath是fc.exe
argues是:c:\program files\t1.txt c:\program files\t2.txt比较的文件名称就成了:c:\program 和 files\t1.txt请教大侠指点
多谢
Process fileDiffProcess = Process.Start(this._exePath,argues);
但是,在参数argues内,我要用到的文件名称要有空格,但是空格又是两个文件名的区分符,
比如:this.exePath是fc.exe
argues是:c:\program files\t1.txt c:\program files\t2.txt比较的文件名称就成了:c:\program 和 files\t1.txt请教大侠指点
多谢
是啊,用progra~1果然可以阿,但是对于不在program files目录下带空格的文件名怎么办呢?
...
using System.Runtime.InteropServices;
using System.Text;
...定义:
[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(
@"J:\wmt ff fffff\wmt 85 fff\dd dfdas.txt", shortPath, shortPath.Capacity);
string s = shortPath.ToString();
MessageBox.Show(s.ToString());结果:
J:\WMTFFF~1\WMT85F~1\DDDFDA~1.TXT上面算是一个例子,其实可以做成个方法,把文件名进行格式化后再比较:_