简体   繁体   English

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

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

I've got an xml file in my AIR app and I'm trying to determine his size. 我的AIR应用程序中有一个xml文件,我正在尝试确定他的大小。 Here's what I did : 这是我所做的:

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

But I've got this error : Error #3003: File or directory does not exist. 但是我遇到了这个错误: Error #3003: File or directory does not exist.

The file.url is working, but the file.size is throwing the error.. file.url在起作用,但是file.size抛出错误。

2nd question (related) : 第二个问题(相关):

Can I check the size of a file in my server with AS3 code ? 我可以使用AS3代码检查服务器中文件的大小吗?

Would it be something as simple as : 会像这样简单吗:

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

What I want to do is : 我想做的是:

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

From the documentation 文档中

Indicates whether the referenced file or directory exists. 指示所引用的文件或目录是否存在。 The value is true if the File object points to an existing file or directory, false otherwise. 如果File对象指向现有文件或目录,则值为true,否则为false。

Adjust your code like this: 像这样调整代码:

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