Copy from network

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
Hi. I’m new when it comes to C# and have some problems with a application I’m developing.*
The scenario is as follows: I want to copy all new files from a directory on our network to the hard drive. Here’s the kicker… *The program will be running from the network drive. The user navigates to the network drive and run my app that copies all the new files in that directory to a specified location on their computer.

I got a lot of tips this post: from http://channel9.msdn.com/ShowPost.aspx?PostID=340403The problem is that the line marked problem generates a SecurityExeption.

The code looks something like this.

public FileCopy(string targetPath)
{
****** try
****** {
***********//sorcefiler
********** DirectoryInfo sourceDir = new DirectoryInfo(“.”)
**********
//Target files
**********
*DirectoryInfo targetDir = new DirectoryInfo(targetPath);//PROBLEM
******* }
******* catch (Exception e)
******* {
********** MessageBox.Show(e.Message, "Unexpected exception", MessageBoxButtons.OK);
*********** return;
******* }

********** //copy new files
**********
*this.copyNewFiles(sourceDir, targetDir);
********** //Startar programmet
********** this.startProgram(targetPath);
******* }

static void Main(string[] args)
{
*** FileCopy files = new FileCopy(arg.Replace("L=", ""));
}

The exeption:
“Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral' failed.

The action that faild was:
Demand
The type of the first permission that faild was:
System.Security.Permission.FileIOPermission
The zone of the assembly that faild was
Intranet”
Any ideas how to fix it without changing permissions in .NET Framework 2.0 Configuration?


More...

View All Our Microsoft Related Feeds
 
Back
Top