Jump to content

Recommended Posts

Posted

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

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...