【问题标题】:excluding .exe file (referenced by my app)不包括 .exe 文件(由我的应用程序引用)
【发布时间】:2010-07-11 19:22:37
【问题描述】:

萨拉姆盖兹! 我做了一个项目,我在它的 bin 文件夹中引用了一个 .exe 文件,现在在一个按钮单击事件中,我想将该 .exe 文件排除/提取/复制到我计算机上的不同路径中。(我正在尝试这个,而我有安装了我的应用)

在c#中

【问题讨论】:

标签: c#


【解决方案1】:

首先,通过选择您添加到项目中的引用、属性、copy local = true,确保将 exe 复制到 bin 文件夹。

然后,要在运行时检索“其他”exe 的路径并复制/移动它,您可以执行以下操作:

using System.IO;
using System.Reflection;

// ...

FileInfo appMainExe = new FileInfo(Assembly.GetExecutingAssembly().Location);
string appFolder = appMainExe.DirectoryName;
string theOtherExe = Path.Combine(appFolder, "my_exe_file.exe");
File.Copy(theOtherExe, "a_new_full_path");  // or File.Move

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 2015-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-17
    相关资源
    最近更新 更多