Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > 在.NET中运行外部程序的3种方法
【标  题】:在.NET中运行外部程序的3种方法
【关键字】:.NET
【来  源】:http://blog.csdn.net/youbl/archive/2006/11/13/1381738.aspx

在.NET中运行外部程序的3种方法

Your Ad Here

在win32中有ShellExecute方法可以使我们启动外部的应用程序,在 .NET FrameWork 中我们可以使用Process类来完成类似的功能。

Process在System.Diagnostics中,所以别忘了:

    using System.Diagnostics;

1) 用Process的静态方法Start

//启动记事本

Process.Start("notepad.exe");

//启动记事本,并打开temp.txt文件

        Process.Start("notepad.exe",@"d:\temp.txt");

    此方法最简单,但功能有限

2) 用带有ProcessStartInfo参数的 Start方法

             ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe");

             startInfo.Arguments=@" d:\temp.txt ";

//启动时最小化

             startInfo.WindowStyle = ProcessWindowStyle.Minimized;

             startInfo.Verb="open";

         Process.Start(startInfo);

3)实例化Process类

             Process process=new Process();

             process.StartInfo.FileName="notepad.exe";

             process.StartInfo.Verb="open";

process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;

             process.StartInfo.Arguments=@" d:\temp.txt";

         process.Start();

第2种方法和第3种方法差不多,他们的可选的功能就比较多了。

 

System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本:【上一篇】
违反并发性: UpdateCommand影响了预期 1 条记录中的 0 条:【下一篇】
【相关文章】
  • .NET改变WinForms的DataGrid.CurrentCell
  • .Net中使文件变成只读文件
  • 用C++.NET创建XML文档
  • STL的std::vector和.NET的ArrayList,何者速度较快?
  • 拥抱变化——从Atlas到ASP.NET AJAX(4):大大简化的了的Extender扩展器控件
  • Flex2+.NET(FlashRemoting方式数据交互)
  • asp.net 2.0 FileUpload控件的简单使用
  • asp.net中生在文章缩略图并加入图片信息
  • c#.net存储过程版本的分页
  • asp.net-身份模拟(轻松一点)
  • 【随机文章】
  • 纯C#钩子实现及应用
  • Linux不是用来“玩”的
  • 使用Windows防火墙十问答
  • IIS与SQL服务器安全加固详解
  • 对N组字符串无重复全排列的算法
  • 黑客如何DDOS攻击Windows系统
  • hpunix中lvmrc文件的配置
  • 祝大家新年快乐
  • 网络上到处充斥着钓鱼网站
  • jboss中使用log4j
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.