C#的地方资源文件单独的文件夹 [英] C# place resource files to separate folder

查看:163
本文介绍了C#的地方资源文件单独的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有资源文件rs.resx,在设计师,我可以添加图像,它点击添加资源,然后指定图像路径。但加入后,图像被放置到资源文件夹。如何指定放置图像文件的图像目录未在资源目录?

I have resource file rs.resx, in designer i can add images to it clicking on "Add resource" then specify path to image. But after adding, image are placed to Resource folder. How can i specify to place image file to Images directory not in Resource directory ?

推荐答案

这是一个有点棘手,但它是可能的。

This is a little tricky, but it is possible.

VS如果该文件添加到资源的检查已经在项目中的某处定义。如果无法找到它,它会创建该文件夹的资源,把一个拷贝到文件中,有,这个文件添加到项目中,并把一个参考到资源设计者文件的这个新副本。

VS checks if the file added to a resource is already defined somewhere within your project. If it can't find it, it creates the folder Resources, puts a copy to the file there, adds this file to the project and puts a reference into the resource designer to this fresh copy of your file.

要避免这种情况,你应该将文件添加到项目中的之前您将其添加到资源文件。如果该文件是不显山露水的项目结构中你可以创建一个文件夹,右键单击它,选择的添加文件的和你之前点击打开文件对话框的的添加的按钮,推小旁边的箭头按钮,然后选择的添加为链接

To avoid this behaviour you should add the file to your project before you add it into the resource file. If the file isn't somewhere within your project structure you can just create a folder, right click it, select Add file and before you click on the Add button of the OpenFileDialog, push on the little arrow next to the button and select Add as link.

现在的文件驻留在您硬盘的地方,无论你像和资源设计者不你的项目文件中创建一个副本,如果你现在添加资源设计器中的文件。

Now the file resides on the place on your hdd wherever you like and the resource designer doesn't create a copy within your project file if you now add the file within the resource designer.

也许这个小图片有助于找到添加为链接的按钮:

Maybe this little picture helps to find the Add as link button:

这篇关于C#的地方资源文件单独的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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