在C#中寻址资源文件 [英] Addressing resource files in C#

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

问题描述

我已将文件添加到资源中,只需点击右键 - >现有项目。现在我想将添加的文件复制到另一个目录中:



 File.Copy( @ 我不知道 @  C:\Users\user-1 \Desktop \ true ); 





我不知道我要用@我不知道写一下来解决添加的资源文件。



我的尝试:



 File.Copy(< span class =code-string> @ 我不知道 @  C:\ Users\user-1 \Desktop \ true ); 

解决方案

您无法使用File方法获取资源。您应该使用Assembly.GetManifestResourceStream。然后,您可以自己将内容(无论是文本还是字节)写入目标文件。



GetManifestResourceStream [ ^ ]

I've added my file into resources with right click -> existing item. Now I want to copy the added file into another directory like this:

File.Copy(@"I don't know", @"C:\Users\user-1\Desktop\", true);



I don't know what I have to write in @"I don't know" part to addressing the added resource file.

What I have tried:

File.Copy(@"I don't know", @"C:\Users\user-1\Desktop\", true);

解决方案

You can't use File methods to get at a resource. You should be using Assembly.GetManifestResourceStream. You can then just write the content, be it text or bytes, to the target file yourself.

GetManifestResourceStream[^]


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

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