1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using System; using System.IO; using System.Reflection; class Program { static void Main() { // 获取当前程序集 Assembly assembly = Assembly.GetExecutingAssembly(); // 读取嵌入的资源文件 //Replace the Namespace.ResourceFileName to your actually assembly namespace.resource name using (Stream stream = assembly.GetManifestResourceStream("Namespace.ResourceFileName")) { if (stream != null) { using (StreamReader reader = new StreamReader(stream)) { string content = reader.ReadToEnd(); Console.WriteLine(content); } } } } } |