[英]Check if LOCAL file exists (Flex 4 Mobile)
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. 问题是,尝试使用
navigateToURL(...)
命令时返回的错误是由Web /文件浏览器处理的,而不是由应用程序处理的。 Is there a way to look for it without trying to open it? 有没有找到它而无需尝试打开它的方法?
Use this: 用这个:
var myfile:File = new File("/sdcard/GNs/"+file);
if (myfile.exists)
{
// your code here
}
else
{
// your code here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.