升级到 Silverlight 4 导致 System.Security.SecurityException

发布于 2024-09-04 02:51:05 字数 678 浏览 1 评论 0原文

尝试打开文件对话框,但在调用 ShowDialog 时出现异常。这段代码一直运行良好,但我认为当我升级到 Silverlight 4 时,它引起了一些问题。

代码:

var dlg = new OpenFileDialog { Filter = "CSV Files (*.csv)|*.csv" }; 

if (dlg.ShowDialog() == true)

{
    Upload(dlg.File);
}

例外:

Directory = 'dlg.File.Directory' threw an exception of type 'System.Security.SecurityException'
{System.Security.SecurityException: File operation not permitted. Access to path file.csv' is denied.
   at System.IO.FileSecurityState.EnsureState()
   at System.IO.FileInfo.get_DirectoryName()
   at System.IO.FileInfo.get_Directory()
}

获取目录选项似乎有问题,因为我得到了正确的文件名和文件大小,但没有有关目录和目录名称的信息。

Trying to open a file dialog but I get an exception when calling ShowDialog. This pice of code have always worked fine but I think when I upgrade to Silverlight 4 it caused some problem.

Code:

var dlg = new OpenFileDialog { Filter = "CSV Files (*.csv)|*.csv" }; 

if (dlg.ShowDialog() == true)

{
    Upload(dlg.File);
}

Exception:

Directory = 'dlg.File.Directory' threw an exception of type 'System.Security.SecurityException'
{System.Security.SecurityException: File operation not permitted. Access to path file.csv' is denied.
   at System.IO.FileSecurityState.EnsureState()
   at System.IO.FileInfo.get_DirectoryName()
   at System.IO.FileInfo.get_Directory()
}

It seems like it´s problem to get options for the directory because I got correct filename and file size but no information about the directory and directory name.

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

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

发布评论

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

评论(1

倚栏听风 2024-09-11 02:51:05

如果您尝试调试应用程序,那么您将收到此安全异常。尝试在不进行调试的情况下运行,并检查是否仍然出现此错误。

If you are trying to debug the application then you will get this security exception. Try to run without debugging and check if you are still getting this error.

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