惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

博客园 - 悟空空

Firefox IE兼容性js笔记 Firefox,Safari与IE兼容性问题整理 调用dll给winform程序创建所有用户均可使用的快捷方式 SQL Server获取TEXT字段的内容长度 正则表达式笔记 Silverlight 4简体中文正式版脱机帮助文档安装说明 [原创]利用CPAU静默调用其它程序 - 悟空空 - 博客园 CPAU参数说明 - 悟空空 - 博客园 apache_2.2.4和php-5.3.2安装过程问题整理 Rectangle 属性 SSL网站自动安装根目录证书(整理备用)javascript - 悟空空 - 博客园 NND年年回家这么难买火车票 DoubleAnimation 类 Storyboard 类 - 悟空空 - 博客园 CroppedBitmap 类 Windows Presentation Foundation 中的 Pack URI WPF 性能分析工具 CompositionTarget 类 SolidColorBrush 类 - 悟空空 - 博客园
在cs类中调用嵌入资源并输出流 - 悟空空 - 博客园
悟空空 · 2010-11-19 · via 博客园 - 悟空空

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web.UI;

[assembly: WebResource("MenuPurview.Resource.style.css", "text/css", PerformSubstitution = true)]
namespace MenuPurview
{
    public class MenuCss

    {

    //调用嵌入资源并输出流

        public static string ReadRes(string ResName)
        {
            Assembly myAssembly = Assembly.GetAssembly(typeof(MenuPurview.MenuCss));
            Stream myStream = myAssembly.GetManifestResourceStream(ResName);
            StreamReader sr = new StreamReader(myStream);
            string s = sr.ReadToEnd();
            return s;
        }
    }

}

调用部分

string s=MenuCss.ReadRes("MenuPurview.Resource.style.css") ;