如果我正确理解了您的问题,那么您正在寻找Process.Start.
请参阅此示例(来自文档):
// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
Run Code Online (Sandbox Code Playgroud)
编辑
正如你所说,你需要类似"dir"命令的东西,我建议你看一下DirectoryInfo.您可以使用它来创建自己的目录列表.例如(也来自文档):
// Create a DirectoryInfo of the directory of the files to enumerate.
DirectoryInfo DirInfo = new DirectoryInfo(@"\\archives1\library");
DateTime StartOf2009 = new DateTime(2009, 01, 01);
// LINQ query for all files created before 2009.
var files = from f in DirInfo.EnumerateFiles()
where DirInfo.CreationTimeUtc < StartOf2009
select f;
// Show results.
foreach (var f in files)
{
Console.WriteLine("{0}", f.Name);
}
Run Code Online (Sandbox Code Playgroud)
正如其他人指出的那样,它是Process.Start。例子:
using System.Diagnostics;
// ...
Process.Start(@"C:\myapp\foo.exe");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11894 次 |
| 最近记录: |