获取WPF资源,生成文件

 

            using (Stream stream = Application.GetContentStream(new Uri(reportName + ".rdlc", UriKind.RelativeOrAbsolute)).Stream)
            {
                byte[] bytes = new byte[stream.Length];
                stream.Read(bytes, 0, bytes.Length);

                // 设置当前流的位置为流的开始
                stream.Seek(0, SeekOrigin.Begin);

                FileStream fs = new FileStream(reportPath, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(bytes);
                bw.Close();
                fs.Close();
            }

 

原文地址:https://www.cnblogs.com/nfyz/p/1512792.html