xXcramaXerXx xXcramaXerXx - 1 year ago 64
Vb.net Question

Want to Distribute PDF file with my Visual Basic Project during Deploying

I have Visual Basic (Visual Studio Professional Edition, .NetFrameWork 4.0)
I want to include and Call PDF with my

I include MyPDF.pdf in
and after that I follow the link and call as:


but this is Ok and works, as this in my own PC, but when I install this in another PC (or I displace the PDF from the link as specified) so it fails to open the

So My Question as What I did that during installation also
also install on user computer and which code I use for this?

Thanks in advance :)

Answer Source

Firstly, press on the pdf file in the solutions explorer. Propeties of the file should be as following:

Build Action: Content 
Copy to output directory: Copy always

The path to the file in users computer will be Application.StartupPath & "\Resources\MyPDF.pdf"

Not sure I did not forget something, so tell me if it works :)

EDIT: I see a lot of people are having trouble with this so here is the simplest way I know to deploy a file together with .net program in visual studio:

  1. Drag and drop the file to the solutions explorer
  2. Press on the file in the solutions explorer and modify it's propeties to:

    Build Action: Content;
    Copy to output directory: Copy always

  3. The path to the file to be used in code will be Application.StartupPath & "\filename.txt"
I think there is a way to do it without Application.StartupPath, which may cause problems somehow, but i don't know how

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download