Naresh J
Naresh J

Reputation: 2137

Permmission denied while opening file from Temp folder

In my Temp folder, there is one file which is downloaded from browser. I am trying to open this file using DesktopAPI like this :

File f = new File("C:/DOCUME~1/NJAGAD~1/LOCALS~1/Temp/7870249-0/1234567.pptx");
      try {
        Desktop.getDesktop().open(f);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

But it gives error like :

java.io.IOException: Failed to open file:/C:/DOCUME~1/NJAGAD~1/LOCALS~1/Temp/7870249-0/1234567. Error message: Access is denied.

    at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
    at sun.awt.windows.WDesktopPeer.open(Unknown Source)
    at java.awt.Desktop.open(Unknown Source)

Upvotes: 0

Views: 1078

Answers (2)

Shankar
Shankar

Reputation: 121

I had the same issue and got the error java.io.IOException: Failed to open "PDF" files. Error message: Access is denied. The following solution resolved the issue.

Solution:

Open the PDF reader Go to Edit --> Preferences General --> Select Default Handler --> Select Adobe product --> apply -->ok --> Restart the computer

Upvotes: 1

Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35577

If you want to access folders in windows partition you have to change permission. Otherwise you will get this exception.

Upvotes: 0

Related Questions