I’m trying to use System.IO.File.Exists() on a webplayer application in a C# script to check if a given file is present on the local drive.
As far as the documentation goes, this method is supposed to be compatible with the webplayer.
It compiles fine in editor when setting the target to webplayer.
However, when running it in a browser, it seems to generate an exception, stopping the script execution.
Am I missing something?
You are not allowed to access the system in any form. This not only means File IO, but also System.Environment and larger parts of System.Encryption which rely on System.Environment and similar things that access the system on a low level
The documentation is of no relevance there.
Not due to unity not being the the regular mono but because depending on the platform various to a large number of assemblies are not allowed by definition.
If you want something to checkup, look at the supported namespaces and classes list on the website which mentions whats available in what assembly restriction. Its not fully correct on all aspects, but for fundamental stuff like webplayer subset and mobiles its correct enough to prevent you from wasting time.
A thing to keep in mind with webplayer that also saves time: Anything that relies internally on p/invoke or interopservices will not work for granted basically
Search for ‘Class: File (namespace System.IO, assembly mscorlib)’
You will see that it states that the Exist() method is supported by Webplayer (and when you use it in the editor with webplayer as a target, it compiles fine).