Results 1 to 5 of 5
  1. #1
    JavaCy is offline Member
    Join Date
    Sep 2010
    Posts
    29
    Rep Power
    0

    Default Problem on mkdir

    Hello i create a jar file (netbeans) to create a program.
    When i write this code:

    Java Code:
    File folder = new File("C:/Program Files/test/files");
    folder.mkdir();
    is not working, no folder created!
    Windows XP.

    when i edit the above code for Linux it works like a harm but on windows no :\
    Thank you

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    Do you already have test under Program Files?
    Swastik

  3. #3
    JavaCy is offline Member
    Join Date
    Sep 2010
    Posts
    29
    Rep Power
    0

    Default

    No but i try and this

    Java Code:
    File folder = new File("C:/Program Files/test");
    folder.mkdir();
    with the same result.

  4. #4
    f1gh is offline Member
    Join Date
    Nov 2010
    Posts
    46
    Rep Power
    0

    Default

    Well if the "test" directory, under which you are trying to create the "files" directory doesn't exist, than mkdir() won't work, you need to use mkdirs() which will create the entire directory structure.

    lets say you wanted: c:\home\jacl\scripts\ws
    but neither jacl, nor scripts folder along with ws existed under home, than using mkdirs() will create those directories for you, whereas if those directories don't exist and you use mkdir() it won't work.

    Hope this helps

  5. #5
    JavaCy is offline Member
    Join Date
    Sep 2010
    Posts
    29
    Rep Power
    0

    Default

    @f1gh: works my friend. mkdirs(); is the solution. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •