本文介绍了Silverlight 5信任模式.访问文件系统和本地驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以更高的信任度访问SL应用程序中的整个文件系统?在Windows和Mac上都可以使用吗?通过AutomationFactoryPInvoke还是非托管代码?我需要一个可以读取本地驱动器,文件夹和文件的应用.

Is there any way, any chance at all to access entire filesystem in SL app with elevated trust?That will work both in Windows and Mac?Through AutomationFactory,PInvoke or unmanaged code?I need an app that could read local drives, folders and files.

UDP:好的,似乎可以使用mscorlib中的System.IO类读取文件夹和文件.尽管您仍然无法获得有关本地安装的驱动器的信息. Silverlight的mscorlib中没有DriveInfo:(

UDP: Ok, seems it's possible to read folders and files using classes of System.IO from mscorlib. Although you still can't get information about local mounted drives. There is no DriveInfo in Silverlight's mscorlib :(

推荐答案

好的,我对此有所了解.

Ok I have an idea about this.

在Windows中这非常简单,要获取可以使用AutomationFactory的本地驱动器的列表.谷歌有很多例子.搜索名为SilverlightFileExplorer的内容.

It is straightforward enough with Windows, to get the list of the local drives you can use AutomationFactory. There is plenty amount of examples if you google it. Search for something called SilverlightFileExplorer.

现在在Mac上,您可以使用Directory.EnumerateDirectories("/"),然后它将所有文件夹都保存在根目录中.包括Volumes文件夹,其中包含本地驱动器的快捷方式.我不是伯克利系统发行(BSD)Unix文件系统的专家,所以我不能真正保证它可以在任何Mac上运行,但是这种方法对我来说有效.

Now on a Mac you can use Directory.EnumerateDirectories("/") and then it gets all the folders in the root. Including Volumes folder which contains shortcuts to the local drives. I'm not an expert of Berkeley System Distribution (BSD) Unix filesystems, so I can't really promise that it would work on any Mac, but this approach works on mine.

我仍然在玩.当我开始使用原型时,我可能会通过github或其他方式共享它.

I'm still playing around with that. When I get working prototype I'll probably share it through github or something.

这篇关于Silverlight 5信任模式.访问文件系统和本地驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:05