读取嵌入的资源文件

              var ass = Assembly.Load("cn.fstudio.me.report");
                var names = ass.GetManifestResourceInfo("cn.fstudio.me.report.Alarm.rdlc");
                using (var stream = ass.GetManifestResourceStream("cn.fstudio.me.report.Alarm.rdlc"))
                {
                    StreamReader sr = new StreamReader(stream);
                    var xml= sr.ReadToEnd();
                    sr.Close();
                }
                //using (var ms = new MemoryStream())
                //{
                //    Stream stream=   ass.GetManifestResourceStream("cn.fstudio.me.report.Alarm.rdlc");
                //    byte[] buffer=new byte[1024];
                //    int readLen=stream.Read(buffer,0,buffer.Length);
                //    while(readLen>0){
                //        ms.Write(buffer, 0, readLen);
                //        readLen = stream.Read(buffer, 0, buffer.Length);
                //    }
                //    stream.Close();

                //    //ms.Seek(0, SeekOrigin.Begin);
                //    ms.Position = 0;
                //    StreamReader sr = new StreamReader(ms, Encoding.UTF8);
                //    var xml= sr.ReadToEnd();
                //    sr.Close();
                //}

你可能感兴趣的:(文件)