Is it never possible to get the FullName from a fi

2020-04-20 21:09发布

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?

4条回答
家丑人穷心不美
2楼-- · 2020-04-20 21:36

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

查看更多
Juvenile、少年°
3楼-- · 2020-04-20 21:50

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.

查看更多
Luminary・发光体
4楼-- · 2020-04-20 21:56

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

查看更多
霸刀☆藐视天下
5楼-- · 2020-04-20 21:56

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.

查看更多
登录 后发表回答