开发者

System.IO.Directory.Getfiles Silverlight 4 is not working

I'm using Silverlight 4 OOB & ele开发者_高级运维vated 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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜