簡體   English   中英

檢查本地文件是否存在(Flex 4 Mobile)

[英]Check if LOCAL file exists (Flex 4 Mobile)

我目前正在使用此代碼:

        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);
            }
        }

查找文件,並彈出一個彈出窗口供您下載(如果不存在)。 問題是,嘗試使用navigateToURL(...)命令時返回的錯誤是由Web /文件瀏覽器處理的,而不是由應用程序處理的。 有沒有找到它而無需嘗試打開它的方法?

用這個:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM