开发者

Upgraded to Silverlight 4 cause System.Security.SecurityException

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜