vb.net程序所在目录 vbnet打开指定目录下的文件

在VB.NET中如何取得当前目录的路径?

命名空间:System.Windows.Forms

成都创新互联专业为企业提供张湾网站建设、张湾做网站、张湾网站设计、张湾网站制作等企业网站建设、网页设计与制作、张湾企业网站模板建站服务,10年张湾做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

Application.StartupPath 属性(返回String)

获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。

Application.ExecutablePath 属性(返回String)

获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。

vb.net运行所在目录的应用程序并加参数

可试试下面的方法:

1.可接收参数的外部程序

/// summary

/// 可接收参数的外部程序主函数

/// /summary

static class Program

{

/// summary

/// The main entry point for the application.

/// /summary

[STAThread]

static void Main(string[] paras)

{

string temp = "";

foreach (string str in paras)

{

temp += str + ",";

}

MessageBox.Show(temp);

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

}

2.启动外部程序的方法(给外部程序加参数)

/// summary

/// 调用外部程序窗体

/// /summary

public partial class Invokeprogram : Form

{

public Invokeprogram()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo.CreateNoWindow = true;

proc.StartInfo.UseShellExecute = false;

proc.StartInfo.RedirectStandardOutput = true;

proc.StartInfo.FileName = Application.StartupPath + "\\WindowsFormsApplication1.exe";

proc.StartInfo.Arguments = "-steam -game cstrike"; //传入启动参数

proc.Start();

//string output = proc.StandardOutput.ReadToEnd();

// MessageBox.Show(output);

}

}

VB.NET中怎么找到EXE程序所在的路径

见上图,用鼠标按照上述三个步骤先后次序,一一单击进行选择和设置,“生成输出路径”。

那么,在你的程序代码里使用:

MsgBox(Application.StartupPath)

显示的就是,你的当前默认的相对路径。

也可以按照自己的需要重新设置该路径。

新闻标题:vb.net程序所在目录 vbnet打开指定目录下的文件
当前地址:https://www.cdcxhl.com/article38/hjogpp.html

成都网站建设公司_创新互联,为您提供ChatGPT软件开发用户体验做网站自适应网站营销型网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设