During one of my development i got following error, which occurs when I try to convert image into bits and stored in tables. I solved this by adding before the code
FileIoPermission _perm;_perm = new FileIoPermission("c:\\File.txt",'r'); _perm.assert();
Reference: http://msdn.microsoft.com/en-us/library/fileiopermission.aspx