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

为君一笑 提交于 2019-12-20 04:27:15

问题


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?


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/1378902/is-it-never-possible-to-get-the-fullname-from-a-file-using-silverlight-openfiled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!