简体   繁体   English

使用Silverlight OpenFileDialog从文件中获取全名是永远不可能的吗?

[英]Is it never possible to get the FullName from a file using Silverlight OpenFileDialog?

I want to get the fullname from a file on Silverlight OpenFileDialog, when I try that, Silverlight throws me an error. 我想从Silverlight OpenFileDialog上的文件获取全名,当我尝试这样做时,Silverlight抛出错误。

I saw there is an attribute on FullName saying it is [SECURITY CRITICAL], but I need to display the full path, is it really no way I can do that? 我看到FullName上有一个属性,它表示为[SECURITY CRITICAL],但是我需要显示完整路径,难道我真的无法做到这一点吗?

Well, yes, Silverlight will not allow you to retrieve the full path information. 好吧,是的,Silverlight将不允许您检索完整的路径信息。 Your topic seems to be closely related to this question . 您的话题似乎与此问题密切相关。 Maybe the answers there will shed more light on your question. 也许那里的答案会更加阐明您的问题。

OpenFileDialog won't provide the full name simply because it doesn't want you to alter those files. OpenFileDialog不会仅仅因为不希望您更改这些文件而提供全名。 With Silverlight, you only have access to the isolated storage and the file could be located outside this storage. 使用Silverlight,您只能访问隔离的存储,并且文件可能位于该存储之外。 But you could just open the file and copy it to the isolated storage, and modify it there. 但是您可以打开文件,然后将其复制到隔离存储中,然后在其中进行修改。
Just discovered that bassfriend found this link too and posted it above. 刚刚发现, bassfriend也找到了此链接并将其发布在上面。 My mistake. 我的错。 Then again, the link is in the top-20 of Google. 同样,该链接位于Google的前20名。 :-) :-)

Another reason why you won't get the full filename is because that filename could contain sensitive information. 无法获得完整文件名的另一个原因是,该文件名可能包含敏感信息。 For example, a file in the "My Documents" folder could expose the user login name. 例如,“我的文档”文件夹中的文件可能会显示用户登录名。

Basically, it's a security restriction. 基本上,这是安全限制。 You're not supposed to bypass it, even if it would be possible. 即使有可能,您也不应该绕过它。 If you would find a way around this, MS would probably release a security update to close that leak again... 如果您能找到解决此问题的方法,MS可能会发布安全更新以再次关闭该泄漏...

尝试使用此处记录的File属性: 示例MSDN

The Silverlight OpenFileDialog behaves differently to the standard forms OFD for security reasons. 出于安全原因,Silverlight OpenFileDialog的行为与标准形式OFD有所不同。 If you retrieve the SelectedFile, it actually returns a FileDialogFileInfo object which contains the Name of the file, rather than a path to the file. 如果检索SelectedFile,它实际上返回一个FileDialogFileInfo对象,该对象包含文件的名称 ,而不是文件的路径。 When you think about it, this makes perfect sense - you don't want somebody writing a piece of malicious code that can get a handle into your filesystem. 当您考虑它时,这是很有意义的-您不希望有人编写一段可以进入文件系统的恶意代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM