Air: parent path and applicationDirectory

November 11, 2009 by fMajakovskij

Today I’ve learned that the only way, tested so far, to get parent paths from the applicationDirectory is using the File object constructor:

	var _parentDir:File = new File( File.applicationDirectory.nativePath + "/../" )

It looks that something like this with any combinations of strings:

	var _parentDir:File = File.applicationDirectory.resolvePath("../")

definitely doesn’t work.

4 thoughts on “Air: parent path and applicationDirectory

  1. Quentin says:

    What about File.applicationDirectory.parent?
    I think it should be OK…

    • fMajakovskij says:

      Hi Quentin,
      This was the first thing I did, I forgot to mention it on this post.

      Since applicationDirectory and applicationStorageDirectory as well do not use the complete url scheme but the shortcut one like app:/ and app-storage:/, any use of parent property or url / nativePath manipulations will return null because app and app-storage are root directory.

  2. Tabby says:

    Thank you! I was hunting around for ages trying to find a way to get a relative path from the app directory to a file and
    _parentDir:File = new File( File.applicationDirectory.nativePath)
    worked like a charm ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>