Work around for file permission access error?

B

Brett

When I run my app on a shared drive (J:\ for example), the processing that
should take place doesn't. Running the app from that location in VS.NET
debugger reveals this error:

An unhandled exception of type 'System.Security.SecurityException' occured
in mscorlib.dll.
Additional information: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=-neutral, PublickKeyToken=b77a5c56193e089 failed.

There a big implementation that might make this work:
http://msdn.microsoft.com/library/d...nsfileiopermissionattributeclassctortopic.asp.
I'd like to avoid it in the essense of time. Is there some other create way
to do this? I have administrative rights across the network.

Thanks,
Brett
 
C

Crouchie1998

Add your assembly with full trust to the Global Assembly Cache (GAC)

The FileIOPermissions is only a few lines of code, plus the Import.

Imports System.Security.Permissions

Dim fp As New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\")

Try
fp.AddPathList(FileIOPermissionAccess.AllAccess, "C:\AnotherDirectory")
fp.Assert()
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
fp.RevertAssert()
fp = Nothing
End Try

MessageBox.Show("Done")

Crouchie1998
BA (HONS) MCP MCSE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top