将资源文件夹添加到exe路径 [英] Adding Resources Folder to exe path

查看:242
本文介绍了将资源文件夹添加到exe路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010 Ultimate,我的Resources文件夹中有音频文件,我想将此文件添加到application(exe)安装目录/路径中。如何让这个文件夹在安装过程中添加安装路径?



提前谢谢。

解决方案

< blockquote>项目中的Resources文件夹未与.EXE一起部署。它通常包含作为资源编译到.EXE中的各种文件。将此文件夹添加到安装程序是没有意义的,因为.EXE将不会对它执行任何操作,除非您已经编写了一些内容以专门查找该文件夹中的各种文件。您不能只将文件添加到已部署计算机上的文件夹中,并期望.EXE将这些文件视为您通常处理和访问代码中资源的资源。


我将添加到解决方案1:



项目中包含的文件的构建步骤由相应节点的属性页面控制。将文件添加到嵌入资源时,会将其标记为资源和不复制(到输出目录)。如果要将文件复制到输出目录,则应加载属性页并进行相应的修改。但是,当然,将相同的文件放在可执行模块中嵌入的资源中,并将其副本放在输出目录中是完全没有意义的。你需要选择一种或另一种方式。嵌入式资源的一个好处是:用户将无法修改它。



至于安装,它应该只处理作为结果放置的文件输出目录中的构建。所有其他文件都被视为源代码(当然,仅当项目正确放在一起时)并且应该对安装不可见。也就是说,安装不应该使用任何源代码文件。



-SA


I'm using Visual Studio 2010 Ultimate and I have audio files inside of my Resources folder and I'd like to add this file to application (exe) install directory/path. How do I go about having this folder added the install path during installation?

Thanks in advance.

解决方案

The Resources folder in your project does not get deployed with your .EXE. It normally contains the various files that are compiled into your .EXE as resources. Adding this folder to your installer is meaningless as the .EXE will not do anything with it unless you've coded something to specifically look in that folder for various files. You can NOT just add files to the folder on a deployed machine and expect the .EXE to treat those files as resources as you normally treat and access resources in your code.


I would add to the Solution 1:

The build step for a file included in the project is controlled by the Properties page for the corresponding node. When a file is added to an embedded resource, it is marked as "resource" and "do not copy" (to the output directory). If you want a file to be copied to output directory, you should load the property page and modify it appropriately. But of course, it would be totally pointless to have the same file put in the resource embedded in the executable module, and a copy of it in the output directory. You need chose one or another way. One benefit of the embedded resource is: the user won't be able to modify it.

As to the installation, it should only deal with files placed as a result of the build in the output directory. All other files are considered as source code (of course, only if the project is put together correctly) and should be invisible to the installation. That is, installation should never use any source code files.

—SA


这篇关于将资源文件夹添加到exe路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆