How to programmatically open PDF files in a default PDF reader?

I have a PDF file and you want to open it on the clients desktop (so I don’t know the default directory of my PDF reader) ...

...
File.WriteAllBytes(pdfByteArray, path);
File.Open(path, FileMode.Open);
...

doesn't seem to work here ...

+5
source share
1 answer

Try opening it as follows:

File.WriteAllBytes(pdfByteArray, path);
Process.Start(path);

If it pathends with some extension (for example .PDF) that has a program associated with it, it will be opened using this program.

+22
source

All Articles