Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Desktop, Mobile and non-browser Environments > AIR (Apollo)

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-13-2007, 04:30 PM   #1
xwielder
Senior Member
 
Join Date: Aug 2007
Location: NE Ohio
Posts: 524
Send a message via AIM to xwielder
Default applicationStorageDirectory

Flash CS3
Adobe AIR Beta 1

ActionScript Code:
// All three (3) AIR import classes are needed to handle commonly used file/directory manipulations. import flash.filesystem.File; // Represents a path to a file or directory. import flash.filesystem.FileStream; // Used to open files for reading/writing. import flash.filesystem.FileMode; // Determines the capabilities available to the FileStream object once the file is opened, which include writing, reading, appending, and updating. // WORKING WITH DIRECTORIES (create, delete, move, list) // // **!~ NOTE ~!** // ********************************************************************** // A File object can point to the path of a file or directory that does NOT YET EXIST. // You can use such a File object in creating a new file or directory. // ********************************************************************** // // ** CREATE a Directory using a specific (explicit) path. // //////////////////////////////////////////////////////// // Create the File object variable var testNativeDIR:File = new File(); // Set the (native) path for the File object. // MUST use double '\\' back OR forward slashes.  ("\\" OR "//" will work.) testNativeDIR.nativePath = "C:\\_TEST-DIRECTORY"; // Create the Directory (based on the native path data). testNativeDIR.createDirectory(); // // // ** CREATE a Directory in the User directory of the logged on user. //    Example:  "C:\Documents and Settings\username" // //////////////////////////////////////////////////////// // Create and assign the File object variable. var testUserDIR:File = File.userDirectory.resolve("_TEST-DIRECTORY"); // Create the Directory. testUserDIR.createDirectory(); // // // ** CREATE a Directory in the 'My Documents' folder of the logged on user . //    Example:  "C:\Documents and Settings\username\My Documents" // //////////////////////////////////////////////////////// // Create and assign the File object variable. var testDocumentsDIR:File = File.documentsDirectory.resolve("_TEST-DIRECTORY"); // Create the Directory. testDocumentsDIR.createDirectory(); // // // ** CREATE a Directory on the Desktop of the logged on user . //    Example:  "C:\Documents and Settings\username\Desktop" // //////////////////////////////////////////////////////// // Create and assign the File object variable. var testDesktopDIR:File = File.desktopDirectory.resolve("_TEST-DIRECTORY"); // Create the Directory. testDesktopDIR.createDirectory(); // // // ** CREATE a Directory in the root of where the AIR application was installed. // //////////////////////////////////////////////////////// // Create the File object variable. var testAppResDIR:File = File.applicationResourceDirectory; // Name the Directory. testAppResDIR = testAppResDIR.resolve("_TEST-RESOURCE-DIRECTORY"); // Create the Directory. testAppResDIR.createDirectory(); // // // ** CREATE a Directory to store prefs and such. // //////////////////////////////////////////////////////// // Create the File object variable. var testAppStoreDIR:File = File.applicationStorageDirectory; // Name the Directory. testAppStoreDIR = testAppStoreDIR.resolve("_TEST-STORAGE-DIRECTORY"); // Create the Directory. testAppStoreDIR.createDirectory();

Okay, the above code will generate all my lovely file directories... except for one. This one:
ActionScript Code:
// // // ** CREATE a Directory to store prefs and such. // //////////////////////////////////////////////////////// // Create the File object variable. var testAppStoreDIR:File = File.applicationStorageDirectory; // Name the Directory. testAppStoreDIR = testAppStoreDIR.resolve("_TEST-STORAGE-DIRECTORY"); // Create the Directory. testAppStoreDIR.createDirectory();

Adobe say's this:
Quote:
You can point a File object to the application storage directory. For every AIR application, there is a unique associated path that defines the application store directory. You may want to use this directory to store application-specific data (such as user data or preferences files).
Where is this unique associated path ?!?

I do a computer wide search for _TEST-STORAGE-DIRECTORY to no avail. What am I missing?
xwielder is offline   Reply With Quote
Old 09-14-2007, 09:17 AM   #2
1somniac
Registered User
 
Join Date: Aug 2007
Posts: 8
Default

The applicationStorageDirectory property store the data in the application URL-scheme, which mean you can't access it directly :
Quote:
applicationStorageDirectory property

applicationStorageDirectory:File [read-only]

The url property for this object uses the app-storage URL scheme (not the file URL scheme). This means that the url string is specified starting with "app-storage:" (not file. Also, if you create a File object relative to the applicationStoreDirectory directory (using the resolve() method), the url of the File object also uses the app-storage URL scheme (as in the example).



Implementation
public static function get applicationStorageDirectory():File
You can use other properties like DesktopDirectory or applicationRessourceDirectory if you want to retrieve your file via an URL.
1somniac is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.