1

As silverlight do not have access to local system files, we cannot perform any action on such files like to copy, move, delete, open ect.

In my case i want to get the path of file(s) located on local System, but getting some security exception. Please suggest some possible way to get access to the Local File System.

Thanks in Advance!!

Faizan
  • 766
  • 2
  • 7
  • 19
  • possible duplicate of [Does Silverlight 3 have access to local file system, Open Excel, and print reports?](http://stackoverflow.com/questions/1148182/does-silverlight-3-have-access-to-local-file-system-open-excel-and-print-repor) – 一二三 Nov 26 '11 at 07:33
  • @一二三: possibly not a duplicate. Silverlight 4 applications running with elevated trust outside of the browser do have limited access to the filesystem. – Luke Woodward Nov 26 '11 at 12:40
  • Access to the filsystem in Silverlight is locked down for good reasons. Why do you need local filesystem access? – Luke Woodward Nov 26 '11 at 12:42
  • @Luke Woodward For uploading reason! where i wanna upload some files(images) from local system to the server! – Faizan Nov 26 '11 at 18:32

3 Answers3

2

To read a file from the filesystem in Silverlight, you can't use the pathname of the file. If you're not running out-of-browser with elevated trust, then you're prohibited from accessing this information for security reasons.

However, the FileInfo objects obtained from an OpenFileDialog have a OpenRead() method, which returns a Stream that reads the data from that file. From reading your comment, this appears to be all you need, so I suspect that you don't actually need the paths of files on the user's local system at all.

I gave a similar answer to another question about uploading files in Silverlight a few months ago.

Community
  • 1
  • 1
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
1

If you're not running out-of-browser with elevated trust, then you're prohibited from accessing this information for security reasons.

http://social.msdn.microsoft.com/Forums/silverlight/en-US/da778e7c-e790-4bb2-92b8-cea815789d22/silverlight-4-local-filesystem-access?forum=silverlightnet

0

These tasks are not possible in Silverlight 4 without using Out-of-Browser with Elevated Trust.

In Silverlight 5 its possible after jumping through a few hoops to get an inbrowser app to have elevated trust.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306