WWW and File.Exists to check new file on server

I am aware that we can use WWW class to read the content of a specific file. But I wonder, is there a way to find out if there is a new file put on server, and read that one instead. So, I figured out using File.Exists from System.IO. Could someone point me to a tutorial how these File.Exists and WWW to check a new file on server?

No, File.Exists only works with files on a local connected filesystem. Files on a server always have to be requested via HTTP. What you would need is a HEAD request but unfortunately the WWW class that comes with Unity only supports GET and POST requests.

You have two options:

  • Use a different class for your webrequest that supports the HEAD method. This might help
  • If your webserver supports PHP you can create a PHP file that returns what files are available on your server.

Not all web servers support HEAD for all URLs. Often dynamic content URLs or temporal URLs won’t support it. So the most robust way is the second one.