开发者

Is it possible to see if a particular file exists on file system?

I am using Flex with Flash player. I know with AIR i can access the file system but i am not using AIR.

Can my开发者_开发知识库 application check if a particular file exist when an HTTPService is sent?


The way I solve this problem is to make the request to the server. I then handle the response and check what is in the response. There should be an error in the response if the file was inaccessible.

Although, this could also mean the URL is wrong or that the server refused connection


You can check if a file exists on the local file system using:

import flash.filesystem.*;

var temp:File = File.createTempFile();
trace(temp.exists) // true
temp.deleteFile();
trace(temp.exists) // false

Are you wanting to check if the file exists on the remote machine, the one you are making the HTTP request to?


If you are checking to see if a file exists on the server, it's going to be a server side solution, not a Flex solution. You need some kind of server side scripting language set up (like PHP) that can take the HTTP request, check for the file on the server and then return a response. Should be a pretty easy problem to solve but it has nothing to do with Flex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜