-1

I have a help button on my form when the user clicks it initializes the Help.cs form which has axAcroPDF1 initialized. Everything works as expected but when I build the application and move the release folder to a USB to copy it over to another location it can't read the pdf which is the right thing to do, how can I fix this issue so it takes the file path of the pdf from the current location.

This is my code to initialize the pdf and how I am loading it:

  private void Help_Load(object sender, EventArgs e)
        {
  InitializeAdobe("C:\\Users\\username\\Documents\\Visual Studio 2013\\Projects\\Learning Windows Forms\\TotalReporting\\TotalReporting\\bin\\Release\\Total Reporting Help Guide.pdf");
        }

private void InitializeAdobe(string filePath)
 {
try
{
    this.axAcroPDF1.LoadFile(filePath);
    this.axAcroPDF1.src = filePath;
    this.axAcroPDF1.setShowToolbar(false);
    this.axAcroPDF1.setView("FitH");
    this.axAcroPDF1.setLayoutMode("SinglePage");
    this.axAcroPDF1.Show();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message.ToString());
}

}

   private void Help_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.axAcroPDF1.Dispose();
            this.axAcroPDF1 = null;
        }
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
CodeMan
  • 133
  • 3
  • 19
  • It seems that the PDF file is in the same folder of your application. Then you don't need to specify a path or you can just use one of the may methods that return the current application installation folder – Steve Nov 04 '16 at 16:43
  • @Steve can you please provide a snippet :) – CodeMan Nov 04 '16 at 16:46

1 Answers1

0

Basically you dont need to put file in path like this, because when you run your application, it will file this path on that machine too. so you have to put file at a definite location so that you can get the location at run time(not by hard coded path)You can refer my answer to get the required path. https://stackoverflow.com/a/40157384/6527049

Community
  • 1
  • 1
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197