What is Silverlight/C# equivalent for Java's AccessController.doPrivileged

423 views Asked by At

I'm trying to do some filing with Silverlight and have access the result from Javascript. It is easily done by Java applets through the AccessController.doPrivileged method, for example I can write methods such as SaveToFile or ReadFromFile which are wrapped inside a AccessController.doPrivileged method, and it is done. I wanted to know how can I do the same thing with Silverlight, i.e., do some privileged stuff such as file IO therein.

1

There are 1 answers

1
mjv On BEST ANSWER

By design (for security reasons), Silverlight code cannot access directly the host's file system.
A file may accessed, in reading mode only, if it is selected by way of the File Open Dialog.
The only limited capabilities for writing to files is when the Silverlight application is both ran in Out-of-Browser mode and in the context of Elevated trust. Yet such access is limited to particular well known directory locations (My Documents, My Music etc.)

Isolated storage provides a way for Silverlight applications to create, write and read files, but this type of access is generally "corralled"; again, Silverlight code does not have direct access to the host's file system.