views:

1242

answers:

4

Hi,

I am creating an AIR application using Flex. In it I need 2 directories downloads & uploads. These directories will have downloaded files & uploaded files. But the problem is I am not able to create these 2 directories programmatically & also I am not able to include the 2 directories with the installer in the application directory.

Is there any way to create or include directories in the application directory.

Thanks

A: 

have you tried something like the following

var dir = File.userDirectory.resolvePath("upload directory");
dir.createDirectory();

This will create the directory 'upload directory' if it does not already exist (inside the users home directory).

kenneth
Thats fine.But I need to create the directories in application directory.I am using:var dir = File.applicationDirectory.resolvePath("upload directory");dir.createDirectory();And I am getting:at runtime::SecurityManager$/checkPrivilegeForCaller()
+1  A: 

[...] But I need to create the directories in application directory. I am using: var dir = File.applicationDirectory.resolvePath("upload directory");dir.createDirectory(); And I am getting: at runtime::SecurityManager$/checkPrivilegeForCaller()

This is a know issue. AIR wouldn't allow you to write to the application directory. Instead try writing

  • either to the File.applicationStorageDirectory (application's scratchpad),
  • or to the File.documentsDirectory (stuff user might want to lookup)

Related resources:

Adobe AIR team blogpost

dirkgently
+1  A: 

Create an empty folder inside your Flex project. Right click on your project and go to Properties->Compiler (not exact name but something like that). Make sure it has "Copy nonembedded assets to output directory" (check it if it doesn't). Click Ok.

Export a release build of your AIR app. Do NOT click Finish after the "signing" step. Follow each step until you get to the "assets" screen. It will show you a list of every file and folder in your output (bin-debug, by default) directory.

Check the files you want, uncheck the one's you don't, and click OK. Done. You have your AIR file packaged with whatever file and folder you want.

johncblandii
To clarify (it was late and I was tired; lol):Properties->Flex Compiler and check "Copy non-embedded assets to output directory"On release export, select location to save AIR file and click Next. Sign your application (dev cert or real one), click Next. The AIR File Contents section is the one where you select the files/folders to include.NOTE: On OSX, anything included in the AIR package will be part of the "Package Contents" so the folder is inside the .app file. On Windows it is alongside the exe.Hope that helps.
johncblandii
A: 

Use This Dear :)

var dir:File = File.applicationDirectory.resolvePath("NewFolder");

dir =new File(dir.nativePath.toString());
dir.createDirectory();

Regards

Ali Naqvi

Ali Naqvi