我想在自己程序里调用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请教大侠指点
多谢

解决方案 »

  1.   

    argues本身就是一个字符串阿,argues =“c:\program files\t1.txt  c:\program files\t2.txt”,这样不行啊,怎么括在引号内?请具体点:)
      

  2.   

    这是那个比较程序的问题,它没考虑到长文件名。你在命令行方式下执行结果应该也一样,改成progra~1吧。
      

  3.   

    to: zhy0101(香蕉) 
    是啊,用progra~1果然可以阿,但是对于不在program files目录下带空格的文件名怎么办呢?
      

  4.   

    使用转义符试试:argues ="\"c:\program files\t1.txt\"  \"c:\program files\t2.txt\"",
      

  5.   

    希望能对楼主有所帮助:_)
    ...
    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上面算是一个例子,其实可以做成个方法,把文件名进行格式化后再比较:_