09-08-2012 09:31 AM
hi everyone,
Can any any one explain how to acees files, I am geting the error when i used to access the data from files
pls help me, iam w8ng,
here is my code
var myFile:File = File.applicationStorageDirectory.resolvePath("samp le.txt");
var fs:FileStream;
if(myFile.exists)
Alert.showAlertDialog("File Found");
else {
Alert.showAlertDialog("File Not Found");
}
var fileStream:FileStream = new FileStream();
fileStream.open(myFile, FileMode.READ);
var fileContents:String = fileStream.readUTFBytes(fileStream.bytesAvailable) ;
fileStream.close();in the above code i got output as file not found.
i stored the file in the src folder in the project.
Solved! Go to Solution.
09-08-2012 09:53 AM
So your file only exists as a result of the app being installed, then, vs. being created when the app runs? If so, your file would be in File.applicationDirectory, not in the applicationStorageDirectory.
See This old post for info on mapping aliases to the app sandbox directories.
09-08-2012 05:19 PM
Should'nt it be:
var myFile:File = File.applicationStorageDirectory.resolvePath("samp le.txt");
var fs:FileStream;
if(myFile.exists)
{
trace("File Found");
var fileStream:FileStream = new FileStream();
fileStream.open(myFile, FileMode.READ);
var fileContents:String = fileStream.readUTFBytes(fileStream.bytesAvailable) ;
fileStream.close();
}
else
{
trace("File Not Found");
}
09-10-2012 12:25 AM