简体   繁体   中英

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. 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.

The file.url is working, but the file.size is throwing the error..

2nd question (related) :

Can I check the size of a file in my server with AS3 code ?

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.

Adjust your code like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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