Results 1 to 6 of 6
Thread: Unable To Create Folders
- 09-01-2012, 10:32 PM #1
Unable To Create Folders
Why am I unable to create folders?
I am sure I did everything correct.
Here's my code:
Java Code:import java.io.File; public class Main { public static void main(String[] args) { File file = new File("c:/program files/folder check 12 12"); System.out.println(file.mkdir()); } }Last edited by PhQ; 09-01-2012 at 10:43 PM.
- 09-02-2012, 12:19 AM #2
Re: Unable To Create Folders
This code worked for me:
I had a Temp folderJava Code:File file = new File("c:/Temp/folder check 12 12"); System.out.println(file.mkdir());If you don't understand my response, don't ignore it, ask a question.
- 09-02-2012, 01:35 AM #3
Re: Unable To Create Folders
I am trying to make an installer program, but it doesn't let me to create folders in Program Files folder.
I think it's because I don't have the permissions to do it.
If I do it myself, a window comes up saying Folder Access Denied and I need to click continue.
Is it possible to get those permissions for my JAVA application?
If not - is there a workaround for this?
I have tried using Runtime.exec to do this the 'cmd mkdir' way but I had no luck.Last edited by PhQ; 09-02-2012 at 01:39 AM.
- 09-02-2012, 02:32 AM #4
Re: Unable To Create Folders
Check the doc for the OS you are working on.
If you don't understand my response, don't ignore it, ask a question.
- 09-02-2012, 04:34 AM #5
Re: Unable To Create Folders
andJava Code:if(canCreate(file)){ startInstall(file.getAbsolutePath()); }else{ if(!file.mkdirs()){ JOptionPane.showMessageDialog(this, "Sorry, you don't have the correct permissions to write in this folder. Please choose a diffrent folder.", "Permission Error", JOptionPane.ERROR_MESSAGE); }else{ startInstall(file.getPath()); } }
totally fixed the problem for me.Java Code:public boolean canCreate(File file){ return file.canWrite(); }
I think the permissions has something to do with this: Permissions in the Java(TM) 2 SDK if anyone else is wondering.
- 09-05-2012, 12:13 AM #6
Similar Threads
-
Create PST File, Identify Mail Folders & Add BCC Field in MHT Header
By sherazam in forum Java SoftwareReplies: 0Last Post: 11-22-2011, 01:06 PM -
Create folders dynamically in diff system (known path + IP)
By wiki.horizon in forum Advanced JavaReplies: 5Last Post: 06-28-2011, 09:29 AM -
Unable to create and write files
By DrKilljoy in forum New To JavaReplies: 4Last Post: 09-05-2010, 12:55 AM -
java isDirectory() is not detecting that my folders are folders!
By seandingobat in forum New To JavaReplies: 4Last Post: 10-10-2009, 12:26 AM -
can java.io.File create a list of all files and folders.
By MattStone in forum New To JavaReplies: 20Last Post: 12-17-2007, 03:20 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks