Copying Files from Network to Local



I have a fairly simple C# console app which copies files from a network
folder to a local folder. When the app resides on my local C: drive, it
runs just fine. However, when the app resides on a network drive, copying
the same files from the same source drive and to the same destination drive,
it gives me the following exception:

System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
permToken,CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.IO.DirectoryInfo..ctor(String path)

It seems as if it is assuming the rights of the remote server from which it
is running, even though the app is obviously running as a local process --
this makes absolutely no sense to me. Why does the app assume a totally
different set of permissions just because it resides in a different
location? To me, it seems like the permissions should only be driven by the
process from which it is running, and the identity that is active when
running the application.

Can someone explain to me why I am getting this error, and how I can get
around it so that I can have this app site on a network directory, and copy
files from that same directory to a local directory?

Thanks in advance.

Jerad


.



Relevant Pages

  • Re: Copying Files from Network to Local
    ... working using Code Access Security, ... website has less trust associated with it, and less permissions assigned ... However, when the app resides on a network drive, copying ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Copying Files from Network to Local
    ... The rights that you have ... website has less trust associated with it, and less permissions assigned to ... However, when the app resides on a network drive, copying ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ODBC Connection with SQL Managed Provider
    ... One thing to remember is when running application from a network share, ... > So it was our intent to put a lot of the "forms" into the main app. ... the odbc manager is no quicker than the odbc. ... >>> authorizing the user against a table in the SQL server database. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Environment.CommandLine Security Exception
    ... app from a *network* share. ... > Configuration tool or CASPOL. ... >>> the appropriate permissions, the program should run ...
    (microsoft.public.dotnet.security)
  • Re: .NET new executable
    ... Since there is no network access avaialble, I want to send my app to each ... then you update the data into database. ... If all you are trying to do is send some data to your SQL server, ...
    (microsoft.public.dotnet.general)

Loading