tags:

views:

118

answers:

1

Hi,

How can I create a .txt file using flex 3? And I want to write some datas in to this file...... Is it possible? Any one can help me?

Thanks in advance.. Nimmy

+3  A: 
//set File object    
var file:File=File.documentsDirectory;

    file=file.resolve(“myFile.txt”);
//set Stream object
    var stream:FileStream=new FileStream();
//set FileMode
    stream.open(file, FileMode.READ);
    var data:String= stream.readUTFBytes(Stream.bytesAvailable);
//close file
    stream.close();

different FILEMODE:

FileMode.APPEND: write only, append new data to the bottom of the file;

FileMode.READ: read only, file must exist;

FileMode.UPDATE: both read / write the data where positioned where you want;

FileMode.WRITE: write only , if file doesn't not exist, will be created otherwise will be overwritten;

aSeptik
Note that the File object is only available if you're using AIR. If you're building a Flex RIA, the File object isn't available (for obvious security reasons). For more info: http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
RJ Regenold