I’m just creating a simple calculator in C# (windows form)
I’ve created a “User Help” which is a pdf file, what I want is to display that pdf file if the user clicks on the “Help” button in the WinForm. If assumed that Adobe reader is pre-installed on the user’s machine….
How to open the pdf file on button click in winForm?
I don’t plan to provide this pdf file on hard disk of user. Which means that I have to embed this pdf into the calculator (winForm) and have to display it on the button click.
Kindly guide me with the best practise for displaying an embedded file in winForm.
I would put it on within my program folder, add a link within my Start Menu folder to allow a direct access (without starting my tool) and just at on some click event
System.Diagnostics.Process.Start(@".\Manual.pdf");Update
Ok, now we come to a completely new question: How to embed a file in my application and start it?
For this question you’ll find already several answers here, but here is the short version:
byte[]fromProperties.Resources.NameOfResourceWith these steps you reference your file where ever it exists within your structure. If you like that a copy of your pdf file will be put into a subfolder Resources within your project, just skip the points one and two in the above list.
To get your pdf now opened, you’ll have to write the byte[] down to disk (maybe with
Path.GetTempFileName()) and start it with Adobe Reader. (Don’t forget to delete the file after usage)