0

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

在此处输入图像描述

如何访问文件?

我试过这个:

 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);

            }
        }
4

0 回答 0