How to open a pdf from a network folder

I have a network folder (not local) that contains a bunch of pdfs.
I would like to be able to open a pdf from that folder in Adobe (Assume the user has adobe installed)
I’ve used both my docName variable and hardcoded the entire file path, and neither one works.
I’ve used all combinations of /, //, , \ as folder separators that I can think of as well

I’ve tried

  1. Application.OpenURL("file:\path" + docName); - This one does nothing
  2. Process.Start("file:\path" + docName); - This one at least tells me “cannot find the file specified”

The total size of the folder is around 5 gigs, so I don’t want to put them in a resources folder inside the project.
There are spaces in the network path, and I’ve heard that can affect it, but I have no control over the naming convention for the drive.
Surely there is a way to do this?

What does this have to do with unity?

Lets look at the 2 options you already tested:

It’s supposed to open a url in a browser… not a pdf in adobe.

And Process.Start:

This starts processes… programs.

Take a look at the example code at the bottom, you pass in the name of the program to open, and then other parameters that that program might take (like the file to be opened by said program).

So…no sooner did I post this…

Application.OpenURL does work, it was my mistake on the file path being used. The properties for the pdf filepath didn’t include the subfolder that its in. So my c# code was correct, my file path was not.

Thanks anyway though!

1 Like