Nimmy
Nimmy

Reputation: 5381

Open a file in flex 3

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

Upvotes: 2

Views: 1595

Answers (1)

Luca Filosofi
Luca Filosofi

Reputation: 31173

//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;

Upvotes: 3

Related Questions