视觉工作室中的不同构建选项,如内容,资源和嵌入式资源? [英] Different build option in visual studio like content, resources and embedded resource?

查看:40
本文介绍了视觉工作室中的不同构建选项,如内容,资源和嵌入式资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不影响我的exe的情况下更改运行时的图像文件。



我尝试了什么:



i在我的项目中放置了两个图像,并将一个图像的构建操作从无变为资源,另一个从无变为内容,并将副本设置为始终复制。当我从我的调试文件夹中删除我的图像,其构建操作是内容并运行我的exe两个图像对exe没有影响,如果我删除那个图像。

I want to change the image file on a runtime without effecting my exe.

What I have tried:

i put two images in my project and change the build action of one image from none to resource and the other from none to content and set copy to directory as "Copy Always".when i am deleting my image from my debug folder whose build action is content and running my exe both images appeared no effect on exe if i delete that one image.

推荐答案

如果你的嵌入了图像,您无法在不重建EXE文件的情况下在运行时更改它。如果它没有嵌入,那么它在构建时就在EXE外部,需要安装程序将其与EXE文件一起复制到生产文件夹。



在这种情况下,我不建议更改文件 - 它将在开发中工作,但可能会在生产中失败,因为安装目录将位于程序文件下,并且安全措施不允许在没有管理员访问权限的情况下进行修改。



我要做的是将图像存储在用户数据区中 - 并从安装程序中将其复制到那里 - 可以毫无问题地进行更改。请参阅此处:我应该在哪里存储数据? [ ^ ] - 它显示在哪里存储数据以及如何访问它。
If your image is embedded, you can't change it at run time without rebuilding the EXE file. If it isn't embedded, then it is external to your EXE when it's built and will need to be copied to the production folder along with the EXE file by your installer.

Under those circumstances, I wouldn't recommend changing the file - it'll work in development, but will likely fail in production because the installation directory will be under "Program files" and security measures do not allow modifications there without Admin access.

What I would do is store the image(s) in the user data area - and copy them there from your installer - where they can be changed without problems. See here: Where should I store my data?[^] - it shows where to store data and how to access it.


这篇关于视觉工作室中的不同构建选项,如内容,资源和嵌入式资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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