Save File in Adobe Flex -AIR

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:WindowedApplication xmlns:mx=”” layout=”absolute” creationComplete=”onCreate(event)”>
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.filesystem.File;
function onCreate(e:Event):

var file:File = File.desktopDirectory; //Set the Directory location to Desktop
file = file.resolvePath(
“test.txt); //File Name
fileStream:FileStream = new
FileStream();   // Create new FileStream to Perform Read or Write, FileMode.WRITE); // Open file in WRITE Mode
“Hello World”); //Write Hello World into test.txt
fileStream.close(); //Close the File Stream


This code creates a file named test.txt with content “Hello World” in desktop folder.

The desktopDirectory property provides a way to reference the desktop directory that works across platforms. If you set a File object to reference the desktop directory using the nativePath or url property, it will only work on the platform for which that path is valid Similarly documentDirectory /applicationStorageDirectory /applicationDirectory can be used to represent the folder.

var file:File = new File();
file = file.resolvePath(

This will work in windows platform and stores file in user mentioned location.