在WPF项目资源

时间:2016-03-02 08:49:00

标签: c# wpf pdfviewer

我的WPF项目中有一个包含pdf文件的文件夹,如下所示。

enter image description here

如何访问文件?

我试过这个:

 fileList.Add(new FileList() { FileName = "AngularJS Example", FilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//media/pdf/AngularJS-Example.pdf" });

还有这个:

            fileList.Add(new FileList() { FileName = "AngularJS Up And Running", FilePath = "Reader.AngularJS-Example.pdf" });

FilePath是一个字符串,可以传递给期望字符串的Foxit PDF Viewer方法。

this.axFoxitCtl1.OpenFile(filePath);

调整:

档案:

fileList.Add(new FileList() { FileName = "AngularJS Up And Running", FilePath = "Reader.AngularJS-Example.pdf" });

浏览器:

public ViewerTemplate(string fileName)
        {
            InitializeComponent();
            var assembly = Assembly.GetExecutingAssembly();
            var resourceName = fileName;

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            using (StreamReader reader = new StreamReader(stream))
            {
                string result = reader.ReadToEnd();
                this.axAcroPDF1.LoadFile(result);

            }
        }

0 个答案:

没有答案