I've Googled and searched stackoverflow for this but I've not found an answer that is suitable.
All I want to do is place a button a form, the code behind this button will contain a reference to a location on a harddrive where a pdf file is stored. All I want to do is have it so that when the user clicks the button the pdf file opens in the machines selected pdf reader (this is an internal application so the 2-3 machines that access it will always have adobe acrobat on them).
I've no idea which (if any) of the built in .NET classes can do this.
EDIT: There will be 100's of pdfs all added throughout time, I will have a path reference to one pdf per order in my system which points to a file storage server where the PDF lies. The PDF is not locally hosted.
How can this be done in the simplest sense?
To use the extension, right-click on a PDF link and select the "Open in PDF viewer" item. The extension downloads the PDF file in your default downloads directory and then executes the external command to open the downloaded file with the default PDF viewer (e.g. Adobe Acrobat Reader or FoxIt PDF reader).
To view PDF files on your Windows PC, you first need to download a PDF reader. Luckily, many PDF readers, like Adobe Acrobat, have free versions, so you don't have to pay to read PDFs on your computer. Simply download the reader from the internet and follow the prompts to install it on your computer.
You can simply use this code
System.Diagnostics.Process.Start(@"c:\myPdf.pdf");
It will open the file you provide with its associated default program
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With