繁体   English   中英

在AIR应用程序中跟踪文件的大小+服务器文件的跟踪大小?

[英]Tracing the size of my file in my AIR app + tracing size of my server file?

我的AIR应用程序中有一个xml文件,我正在尝试确定他的大小。 这是我所做的:

var file:File = File.applicationStorageDirectory.resolvePath("horaires3.xml");
trace(file.url); //path to the file
trace(file.size); 

但是我遇到了这个错误: Error #3003: File or directory does not exist.

file.url在起作用,但是file.size抛出错误。

第二个问题(相关):

我可以使用AS3代码检查服务器中文件的大小吗?

会像这样简单吗:

var myURL:URLRequest = new URLRequest("http://www.mywebsite/my_xml.xml");
trace(myURL.size);  

我想做的是:

If (file.size == myURL.size){
//do nothing
}
else{
downloadmyURL();
}

文档中

指示所引用的文件或目录是否存在。 如果File对象指向现有文件或目录,则值为true,否则为false。

像这样调整代码:

if (file.exists) {
    trace(file.size); 
} else {
    trace("File does not exist (yet!)");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM