网站建设资讯

NEWS

网站建设资讯

vb.net运行目录 vbnet打开指定目录下的文件

vb.net主要编写的代码在哪个文件目录下?

VS2005为例:

10年积累的做网站、网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有南明免费网站建设让你可以放心的选择与我们合作。

我的文档--Visual Studio 2005----Projects

在这面找到你的项目,打开项目文件夹,再打开项目文件夹,以WindowsApplication1为项目名为例:

我的文档\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1

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中用button打开程序运行的根目录

这个就是你要的了!希望你能用!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim AppPath As String = Directory.GetCurrentDirectory() '获取应用程序的当前工作目录

Process.Start(AppPath) '打开当前目录

End Sub

忘了说,这个要引用命名空间!

把Imports System.IO 写到代码最上边就好了!

如何实现VB.NET获取程序运行路径

System.Environment.CurrentDirectory

这才是vb.net的获取程序运行路径的方法


分享名称:vb.net运行目录 vbnet打开指定目录下的文件
URL网址:http://cdweb.net/article/doedcsd.html