Reputation: 116
I'm using Silverlight 4 OOB & elevated trust.
I need to get all the filenames on specific directory & populate an object List(Of String)
The compiler throws an error "Method not found" on .Getfiles() method.
Dim files() As String = System.IO.Directory.Getfiles(Path) 'this line is failing..
Help!
Upvotes: 2
Views: 1695
Reputation: 189457
The GetFiles
is marked as "Security Critical" and therefore cannot be used from your code.
You will want to use the EnumerateFiles
method instead. GetFiles
is sooo .NET 1.0, EnumerateFiles
is much slicker, even in the full framework you'd want avoid this older Array returning API if you can.
Upvotes: 3
Reputation: 7103
As far as I know you cannot directly access the whole hard drive using Silverlight OOB.
Quoting from Silverlight site:
When running in a trusted environment, you can access only files in user folders, specifically the MyDocuments, MyMusic, MyPictures, and MyVideos folders. Although this makes sense from a security point of view, it’s limiting. You want to enable the user to drag their data from any location. As it stands right now, if you try to drop a file from a location other than stated above, Silverlight will throw a security error.
Please refer to this link for details on how to work with the hard drive using Silverlight OOB: http://www.silverlight.net/learn/overview/out-of-browser-applications/advanced-silverlight-out-of-browser-introduction#Exercise3
Upvotes: 0