Reputation: 599
I'm currently using this code:
private function getFile(file:String):void
{
var openFile:URLRequest = new URLRequest("file:///sdcard/GNs/"+file);
try {navigateToURL(openFile);}
catch(e:Error)
{
var download:URLRequest = new URLRequest("http://"+file);
new DLAlert().open(this, true);
}
}
to find a file, and give a popup for an optional download if it does not exist. The problem is, the errors returned when trying the navigateToURL(...)
command are handled by the web/file browser, and not by the app. Is there a way to look for it without trying to open it?
Upvotes: 0
Views: 2137
Reputation: 15847
Use this:
var myfile:File = new File("/sdcard/GNs/"+file);
if (myfile.exists)
{
// your code here
}
else
{
// your code here
}
Upvotes: 3