c# 怎样使用嵌入资源呢?? 在debug目录里面有一个test.txt ,属性已经设置为嵌入式资源了,请问应该怎样读取这个test.txt呢?谢谢了~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string s = 项目命名空间.Properties.Resources.test;//文件会当做文本保存。 Assembly assem = this.GetType().Assembly;//比如:ResourceTest.NewFolder1.test.txtstring resName = "YourNamespace.FolderName.FileName"; using (Stream stream = assem.GetManifestResourceStream(resName)){ using(StreamReader sr = new StreamReader(stream)) { richTextBox1.Text = sr.ReadToEnd(); }} 运行后提示 the name 'Properties' does not exist in the current context ? 哪里出错了呢? byte[] bytes = YourNameSpace.Properties.Resources.Test;string s = Encoding.Default.GetString(bytes);richTextBox.Text=Properties.Resources.Test; datagridview焦点问题 C#如何创建虚拟串口,不用串口工具,自己写代码,求帮助 怎么规定RichTextBox控件中RTF的样式? c# 命令行参数 问题?求教!! Winform三层构架有哪些可用的中间件,怎么部署 考试系统倒计时问题,管理员在后台设定考试时间,怎么传送到js倒计时里呢? 关于从access中读取到dataset中的问题 快捷键(ctrl+Q) 求助!!C#如何操作V表!> VS中如何使用事务阿? listview不响应事件? 想得头疼,求个sql语句
Assembly assem = this.GetType().Assembly;
//比如:ResourceTest.NewFolder1.test.txt
string resName = "YourNamespace.FolderName.FileName";
using (Stream stream = assem.GetManifestResourceStream(resName))
{
using(StreamReader sr = new StreamReader(stream))
{
richTextBox1.Text = sr.ReadToEnd();
}
}
运行后提示 the name 'Properties' does not exist in the current context ? 哪里出错了呢?
string s = Encoding.Default.GetString(bytes);richTextBox.Text=Properties.Resources.Test;