wood burning stoves*
The moose likes I/O and Streams and the fly likes Program Cannot Write To Hard Drive: Windows 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Program Cannot Write To Hard Drive: Windows 7" Watch "Program Cannot Write To Hard Drive: Windows 7" New topic
Author

Program Cannot Write To Hard Drive: Windows 7

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

I am using Windows 7 and Java 6 update 20. My program has a user interface through which data is passed and must be written, but Windows will not allow my prgram to write to the hard drive. How do I get my program to request permission to write to the hard drive?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You need to tell us some details. What does your code look like? What error are you getting? What is the path you are trying to write? Do you have permission to write there?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

The program, at start up, attempts to copy a text file from an encrypted archive. The archive uses the TrueZip classes, which on there own function very well. Attempting to copy a blank text file at start up has the result of prompting the user to enter a password which allows the rest of the program to load and start. If I set Windows to allow all permissions, the program starts perfectly. There is also no error message, because as you can see, the program exits if the text file is not extracted. This problem has to do with the permissions granted on Windows Vista and Windows 7. Other programs, upon the first time starting up, ask for this permission and then never ask it a second time, if I am correct. There must be some way of granting a java program permission once and for all, because the the code written in Java runs extremely quickly and brilliantly.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Either PostRealCode or TellTheDetails. java.io.File has no "copyTo" method. java.nio.file.Path (since Java 7) does but you're not using that in that code snippet. So either you haven't posted your real code, or you should tell us from which library this "File" class comes from.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Sorry for not posting the details. It is not a java.io.File. It is a de.schlichtherle.io.File (TrueZip classes) which contains the copyTo method. I just tried something and the program is able to write to the hard drive. I rightclicked on the folder in which the program files reside and manually gave the program permission, but there must be some way of doing this programatically. The dummy file is written to the user folder and the program then starts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program Cannot Write To Hard Drive: Windows 7