【问题标题】:Run an exe file with dependencies VB.Net运行带有依赖项 VB.Net 的 exe 文件
【发布时间】:2014-11-23 03:40:29
【问题描述】:

我知道有很多关于这个主题的问题,但我查看了它们,但找不到我需要的。

我需要在 VB.Net 中运行一个 exe,但该 exe 需要一些位于 exe 文件夹中的文件。当我尝试使用 ShellProcess.Start() 运行 exe 时,exe 在我的应用程序文件夹中查找这些文件(并引发错误),而不是 exe 原始文件夹。我无法移动我的应用程序 exe 或外部 exe。

【问题讨论】:

  • 您是指从 Visual Studio 运行程序进行调试,还是在实际部署中运行最终编译的 exe?你在说什么文件?

标签: vb.net exe


【解决方案1】:

您或许可以使用 Windows 启动路径:

exePath = System.Windows.Forms.Application.StartupPath

【讨论】:

    【解决方案2】:

    你试过Directory.SetCurrentDirectory方法吗?它将应用程序的当前工作目录设置为指定目录。将下面的示例更改为您要在调用之前执行的应用程序的路径。

    Imports System
    Imports System.IO
    
    Directory.SetCurrentDirectory("C:\test")
    Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory())
    'Execute an application from C:\test
    

    输出:

    Current directory: C:\test
    

    【讨论】:

    • 完美运行!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-01
    • 2012-07-23
    • 2012-04-12
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多