【问题标题】:XNA calling an imported exe file in projectXNA 在项目中调用导入的 exe 文件
【发布时间】:2013-03-24 06:22:29
【问题描述】:

我希望在运行我自己的项目时调用另一个 exe。

string appRoot =Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

为此,我得到了这个路径:C:\Users\Jeff TungMbp\Documents\Visual Studio 2010\Projects\menuSystemTutorial\menuSystemTutorial\ menuSystemTutorial\bin\x86\Debug\xxxxx.exe

这不是我想去的浴池。

我希望访问这个路径:C:\Users\Jeff TungMbp\Documents\Visual Studio 2010\Projects\menuSystemTutorial\menuSystemTutorial\ menuSystemTutorial\xxxxxx.exe

我不想做像 System.Process(@"C:\xxxxxxx") 这样的硬编码。

我希望访问路径的原因是因为我已经将 .exe 文件导入到我的项目中,我希望访问的路径是 .exe 的确切位置。

有什么办法可以解决这个问题?或者有没有其他方法可以在我的项目发布为安装文件后附加一个 .exe 文件?

谢谢。

【问题讨论】:

    标签: c# xna


    【解决方案1】:

    ,我不相信有一种方法可以直接指向您的 menuSystemTutorial\xxxxxx.exe 路径而不需要自定义情况。

    由于GetExecutingAssembly() 方法获取包含当前正在执行的代码的程序集,并且Visual Studio 在bin\x86\Debug 文件夹下创建您的程序exe,在我看来没有办法做到这一点.

    但是如果可以从原来的路径中得到你想要的路径,你可以使用string.Replace()这样的方法;

    string appRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace(@"bin\x86\Debug\", "");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      • 1970-01-01
      相关资源
      最近更新 更多