0

I have got a Silverlight application. It works with the user DefaultAppPool. Which got all rights on the server. (write/modify/delete etc..)

If I run it locally it is able to create and delete a directory with Directory.CreateDirectory and Directory.DeleteDirectory.

However if I put the silverlight application online it is able to write, but not able to delete.

Is there a way to check what the problem is, why it is not deleted? Does anyone have any suggestions what I can try?

(I also tried the following:

System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(App.Serverpath);
dir.Delete(true);

I checked the Serverpath, it is the correct one!)

Revils
  • 1,478
  • 1
  • 14
  • 31
  • Are you trying to delete a directory locally, or on the server? You shouldn't be able to delete a local directory, unless Silverlight is running with full trust. – McGarnagle Jul 09 '14 at 18:50
  • If I run it locally, it creates a local temporary directory, which is deleted when the application shuts down. If i run it on the server it creates a temporary directory on the server, but this folder is not being removed on shutdown of the application! – Revils Jul 09 '14 at 20:00

1 Answers1

0

Yes. By default, Silverlight is a sandboxed runtime environment. By default, it won't allow you to delete files on the computer where the application is running. However, you can allow it to do this by switching it to Elevated Trust mode. There are basically two ways of doing this. In browser, and out of browser (OOB). Out of browser is simpler, but the user will be required to install the application. Either way, you will need to buy a code signing certificate and sign the Xap package.

For in browser apps, the client's computer will need to be configured explicitly, at the registry level for elevated trust in browser. If the client installs the application as an OOB app, they will not need to do this.

There are many articles on setting up elevated trust, but here is one: Enabling In-browser elevated trust

Note: I'm a little confused by your use of the word "Server" here. Silverlight, generally speaking is a client side technology. You will not be able to delete files on the server directly. If you need to delete files on the server side, you will need to be build some kind of services on the server side (e.g. WCF, or REST), and call the services from Silverlight on the client side. This may be easier because if you really need to delete files on the server, you will only be able to run the Sivlerlight app on the server, which doesn't seem right.

Community
  • 1
  • 1
Christian Findlay
  • 6,770
  • 5
  • 51
  • 103