Open a PDF from a ListBox in C #

1

I try to open a document in PDF format from ListBox with C #. I manage to load the documents that are in the file but it is not displayed in axAcroPDF1 , what I want is to be able to load all the files to this ListBox and be able to select the one that I want and that is shown to me in axAcroPDF1 . Thanks in advance !!!

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD = new FolderBrowserDialog();

            if (FBD.ShowDialog() == DialogResult.OK)

            {
                FileName.Items.Clear();
                string[] files = Directory.GetFiles(FBD.SelectedPath);
                string[] dirs = Directory.GetDirectories(FBD.SelectedPath);

                foreach (string file in files)
                {
                    FileName.Items.Add(Path.GetFileName(file));
                }
                foreach (string dir in dirs)
                {
                    FileName.Items.Add(Path.GetFileName((dir)));
                }
            }

        }


        private void FileName_SelectedIndexChanged(object sender, EventArgs e)
        {
            FileInfo file = (FileInfo)FileName.SelectedItem;
            Process.Start(file.FullName);
        }

        private void axAcroPDF1_Enter(object sender, EventArgs e)
        {

        }
    }
    
asked by Ricardo Vazquez 04.10.2018 в 05:45
source

1 answer

0

You must call the Acrobat Reader executable

    var p = new Process();
    p.StartInfo.Arguments= @"C:\Temp\tests\bin\Debug\netcoreapp2.1\ElPDF.pdf";
    p.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe";
    p.Start();
    
answered by 04.10.2018 в 16:25