System.IO.Directory.Getfiles Silverlight 4 不工作

发布于 2024-12-05 11:21:58 字数 254 浏览 1 评论 0原文

我正在使用 Silverlight 4 OOB &提高信任度。

我需要获取特定目录上的所有文件名&填充对象 List(Of String)

编译器在 .Getfiles() 方法上抛出错误“找不到方法”。

Dim files() As String = System.IO.Directory.Getfiles(Path) 'this line is failing..

帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔嚣张 2024-12-12 11:21:58

GetFiles 被标记为“安全关键”,因此无法在您的代码中使用。

您将需要使用 EnumerateFiles 方法。 GetFiles 是 sooo .NET 1.0,EnumerateFiles 更加灵活,即使在完整的框架中,如果可以的话,您也希望避免使用这个旧的 Array 返回 API。

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.

春夜浅 2024-12-12 11:21:58

据我所知,您无法使用 Silverlight OOB 直接访问整个硬盘驱动器。

引用自 Silverlight 网站:

在受信任的环境中运行时,您只能访问以下位置的文件
用户文件夹,特别是 MyDocuments、MyMusic、MyPictures 和
我的视频文件夹。虽然从安全角度来看这是有道理的
看来,它是有限的。您想让用户能够拖动他们的数据
从任何地点。就目前情况而言,如果您尝试删除文件
从上述以外的位置,Silverlight 将抛出
安全错误。

有关如何使用 Silverlight OOB 处理硬盘的详细信息,请参阅此链接:
http://www.silverlight.net/learn/overview/out-of-browser-applications/advanced-silverlight-out-of-browser-introduction#Exercise3

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文