是否永远不可能使用 Silverlight OpenFileDialog 从文件中获取 FullName?

发布于 2024-08-03 09:50:50 字数 150 浏览 1 评论 0原文

我想从 Silverlight OpenFileDialog 上的文件获取全名,当我尝试这样做时,Silverlight 向我抛出错误。

我看到 FullName 上有一个属性说它是 [SECURITY CRITICAL],但我需要显示完整路径,我真的无法做到这一点吗?

I want to get the fullname from a file on Silverlight OpenFileDialog, when I try that, Silverlight throws me an error.

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?

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

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

发布评论

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

评论(4

谁的新欢旧爱 2024-08-10 09:50:50

OpenFileDialog 不会提供全名,因为它不希望您更改这些文件。使用 Silverlight,您只能访问独立存储,并且文件可能位于该存储之外。
但您可以打开文件并复制到隔离存储,并在那里修改它。
刚刚发现bassfriend也发现了这个链接并将其发布在上面。我的错误。话又说回来,该链接在 Google 中排名前 20。 :-)

您无法获得完整文件名的另一个原因是该文件名可能包含敏感信息。例如,“我的文档”文件夹中的文件可能会暴露用户登录名。

基本上,这是一个安全限制。即使有可能,您也不应该绕过它。如果你能找到解决这个问题的方法,微软可能会发布一个安全更新来再次关闭该漏洞......

OpenFileDialog won't provide the full name simply because it doesn't want you to alter those files. With Silverlight, you only have access to the isolated storage and the file could be located outside this storage.
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. My mistake. Then again, the link is in the top-20 of Google. :-)

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...

王权女流氓 2024-08-10 09:50:50

嗯,是的,Silverlight 不允许您检索完整路径信息。您的主题似乎与此问题密切相关。也许那里的答案会对你的问题有更多的启发。

Well, yes, Silverlight will not allow you to retrieve the full path information. Your topic seems to be closely related to this question. Maybe the answers there will shed more light on your question.

鹿童谣 2024-08-10 09:50:50

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

Try to use the File property as documented here:
Example,
MSDN

夏雨凉 2024-08-10 09:50:50

出于安全原因,Silverlight OpenFileDialog 的行为与标准形式 OFD 不同。如果检索 SelectedFile,它实际上返回一个 FileDialogFileInfo 对象,其中包含文件的名称,而不是文件的路径。当你仔细想想,这是完全有道理的——你不希望有人编写一段可以获取你的文件系统句柄的恶意代码。

The Silverlight OpenFileDialog behaves differently to the standard forms OFD for security reasons. 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. 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.

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