views:

541

answers:

1
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

Arguments: << path >> Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=4.0.41108.0&amp;File=mscorlib.dll&amp;Key=FileSecurityState_OperationNotPermitted

The line of code above has an error [FileSecurityState_OperationNotPermitted]

A: 

It sounds like your application is running in partial trust. To use a FileStream, you'll need to request elevated trust:

By default, Silverlight-based applications run in partial trust, which means they run within a security sandbox. Sandboxed applications have restricted access to the local computer and are constrained in other ways that help prevent malicious behavior.

From the Silverlight 4 FileStream documentation (emphasis mine):

When it is called by an elevated-trust application, exposes a Stream around a file, supporting both synchronous and asynchronous read and write operations.

EDIT: You can set an application to require elevated trust by setting the "Require elevated trust when running outside the browser" in your Silverlight project settings.

Michael Petrotta
Thank you, but how?
xscape
How to what, set the app to require elevated trust? See my edits.
Michael Petrotta