File.Copy

G

gary.hibbard

I've got an InfoPath form that I am developing in Visual Studio.NET.
It queries a database containing over a million filenames/locations on
a local server. I would like to be able to generate a "copy" button
for each search result that allows you to copy the file from the server
to a directory on the local machine (C:\testFolder in my example). For
now I am just trying to copy a local file to a different filename.
Here's the code I'm using for the OnClick:

string sourceFile = @"C:\\testFolder\\test1.txt";
string destinationFile = @"C:\\testFolder\\test2.txt";
System.IO.File.Copy(sourceFile, destinationFile, true);

I am getting this error message:

System.Security.SecurityException
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed

Obviously these screams "PERMISSIONS!"; however I have added everyone
to the security permissions for the "testFolder" directory and allowed
full control. Test2.txt does not exist and Test1.txt is not open.
Does anybody have any idea why? Or maybe an alternative method? The
files on the server are plain text, BTW.

Thanks,
Garyman99
 
R

RaghuRam

Hi,
Can you please let me know how i can make it fully trusted so that i
can access the file system objects.

Regards,
Raghu
 
G

gary.hibbard

Hello everybody,

I figured out that I had to go in to my .NET Framework Configuration in
Administrative Tools and go in to Runtime Security Policy and click
Adjust Security Level for Each Zone. From there, I selected the zone
in question (Intranet) and pulled the security up to full trust. The
application then worked--however, I ended up changing ideas in the end
anyway, haha. I just created a link--makes it easier.

-Gary Hibbard
 

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

Similar Threads

How do I get passed security issues while developing? 1
Openfiledialog 1
Copy Shortcut 2
copyfile method path not found 2
copying Excel file without opening file 2
Wait Form 1
Export SQL 1
InfoPath 2k3 2

Top