By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

Work around for file permission access error?

P: n/a
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/de...sctortopic.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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Nov 21 '05 #2

P: n/a
Actually, this worked perfectly:
http://support.microsoft.com/default...en-us;832742#7

The only problem is that .NET Wizard "Trust an Assembly" part seems to not
let you "add" assemblies. If the version on an assembly changes, you have
to go through the wizard again. Any ideas how to get around that? Is there
a way to append?

Thanks,
Brett

"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:Or*************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.