升级到 Silverlight 4 导致 System.Security.SecurityException
尝试打开文件对话框,但在调用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试调试应用程序,那么您将收到此安全异常。尝试在不进行调试的情况下运行,并检查是否仍然出现此错误。
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.