假如有如下需求:
将2个文件放到一个程序一起打开,我们可以这么做:
引入命名空间:Using System.Diagnostics;
这个命名空间下面有这样一个类:process,具体使用如下:
--------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
string baidu = "www.baidu.com";
string google = "www.google.com";
Process.Start("IExplore.exe",baidu+" "+google);
}
}
}
----------------------------------------------------------------------------------
运行之后我们可以看见IE浏览器打开了,并且地址栏里面是这样显示的:http://www.baidu.com%20www.google.com/
地址栏里面同时显示了baidu的参数和google的参数。
这样我们就很容易看出start方法主要是打开程序,然后将相关信息传入进去,因此我们可以这么应用。
假如我们要看2个文件的内容是否相等:
--------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
string file1 = "文件完全路径";
string file2 = "文件完全路径";
string softwarepath = "对比工具完全地址";
Process.Start(softwarepath,file1+" "+file2);
}
}
}
----------------------------------------------------------------------------------
这样我们就能通过对比工具一次打开2个文件了。
更多信息可以访问MSDN:http://msdn.microsoft.com/zh-cn/library/system.diagnostics.process.aspx