can't create persistent directory or subdirectories, get PATH_EXISTS_ERR

2 posts, 2 answers
  1. Answer
    Roger
    Roger avatar
    183 posts
    Member since:
    Sep 2007

    Posted 26 Oct 2013 Link to this post

    Hi,
    have got a file system handle and can create a file on the root directory but am trying to create a subdirectory for my app where the files are stored. I use the command:

    fileSystem.root.getDirectory("/lightning/attachments/",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+fileErrorCode(error.code));})

    where fileErrorCode converts the code into a text sting as per the phonegap FileError code API.

    I get back  an error code of 12 which translates to "PATH_EXISTS_ERR"
    Have tried adding the file system root to the path with the same result.
    Lookin on the web I found a similar thing on google groups:
    https://groups.google.com/forum/#!msg/phonegap/CUJO1qLZK0g/PgByaUEykoQJ
    who recommends adding to config.xml:
    <feature name="http://api.phonegap.com/1.0/file"/>   with the appropriate phonegap version of course.
    but where do I add it (if this is the solution).
    I can see from the Icenium xml for Android that the file plugin is included.
    I am testing on a Galaxy S3 & all the examples show writing and reading in the root directory (which works)
    Probably my next post will be how to write and read to the subdirectory !!!
    Any suggestions??


  2. Answer
    Roger
    Roger avatar
    183 posts
    Member since:
    Sep 2007

    Posted 26 Oct 2013 Link to this post

    Found the problem...need to do it simply and 1 at a time...so

    fileSystem.root.getDirectory("lightning",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+ fileErrorCode(error.code));})

    creates the directory "lightning"
    and
    MyApp.fileSystem.root.getDirectory("lightning/attachments",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+fileErrorCode(error.code));})

    will create the subdirectory "attachments" on "lightning"...checked the phone folders and there it is !!!! Lightning/attachments
Back to Top