最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
启动关联的应用程序打开特殊文件 zlyperson(原作)-Windows开发-.NET教程-
时间:2022-07-02 11:28:03 编辑:袖梨 来源:一聚教程网
启动关联的应用程序打开特殊文件 zlyperson(原作)
原文是C#,我把它改成了VB.但未来得及测试.若发现什么问题请告之.
这篇短文将演示如何启动与特殊文件关联的应用程序来打开特殊文件,而不必知道关联的应用程序的具体位置和名称。比如,你要打开demo.bmp,通常在Windows下是MSPaint.exe与之关联的。VB.Net启动关联的应用程序打开特殊文件,需要用到.NetFrameWork System.Diagnostics命名空间。
下面,我们将构造一个任何关联程序的启动器,建一个VB文件Starter.vb。
imports System;
imports System.IO;
imports System.Diagnostics;
public class Starter
public shared sub new(args as string())
'首先,建立进程启动信息的结构
dim pInfo as new ProcessStartInfo();
pInfo.UseShellExecute = true;
dim i as integer
for i = 0 to args.Length-1
if File.Exists(args[i]) then
pInfo.FileName = args[i];
'启动进程
dim p as Process = Process.Start(pInfo);
end if
next
end sub
end class
编译Starter.vb
执行Starter test.bmp test.xls
原文是C#,我把它改成了VB.但未来得及测试.若发现什么问题请告之.
这篇短文将演示如何启动与特殊文件关联的应用程序来打开特殊文件,而不必知道关联的应用程序的具体位置和名称。比如,你要打开demo.bmp,通常在Windows下是MSPaint.exe与之关联的。VB.Net启动关联的应用程序打开特殊文件,需要用到.NetFrameWork System.Diagnostics命名空间。
下面,我们将构造一个任何关联程序的启动器,建一个VB文件Starter.vb。
imports System;
imports System.IO;
imports System.Diagnostics;
public class Starter
public shared sub new(args as string())
'首先,建立进程启动信息的结构
dim pInfo as new ProcessStartInfo();
pInfo.UseShellExecute = true;
dim i as integer
for i = 0 to args.Length-1
if File.Exists(args[i]) then
pInfo.FileName = args[i];
'启动进程
dim p as Process = Process.Start(pInfo);
end if
next
end sub
end class
编译Starter.vb
执行Starter test.bmp test.xls
相关文章
- 过山车之星2豪华版与标准版内容一览 11-02
- 龙腾世纪4影障守护者守望者宝库内容说明 11-02
- 龙腾世纪4影障守护者第三个盾牌谜题攻略 11-02
- 龙腾世纪4影障守护者第二个盾牌谜题攻略 11-02
- 龙腾世纪4影障守护者第一个盾牌谜题攻略 11-02
- 使命召唤黑色行动6飞鸟串烧成就攻略 11-02