File.Copy Access Denied

S

Shailesh Gajare

Hi All,
I have creating an ASP.Net application with two web servers. I am
uploading a file which is being uploaded on one of the server, I want to
copy the uploaded file on the other server at the same time.

It says Access Denied.

I am using File.Copy ( Source , Destination , true ) command in my code,
where
Source : the current physical location of the uploaded file
Destination : the physical location of the other server i.e.
\\IPAddress\SharedFolder
True : To overwrite the file if it exists

I have given rights for everyone on SharedFolder, but still it says Access
denied.

Is it that I have to provide login and pwd in my code.
Is it that I have to NetworkCredential class in my code? if Yes how do I
do.

What is that I am missing?
How do i give rights of ASPNet user of one machine to shared folder of other
machine.

Thanks for your help,
Shailesh Gajare
 
M

Mr Newbie

Im not quite sure if unerstand you. On the Server you are uloading the
file, but at the same time you want to copy the file you are writing to to
another file ?

If so, then it will probably deny you access because of the mode in which it
uploads. You will probably have to wait until the file upload has completed
to do this.

Mr N
 
S

Shailesh Gajare

I tried doing this in debug mode and waited for time to upload the file. I
went to the server to check the file has uploaded perfectly or not then,
then i countinued to debug the lines of copying the same file from Server1
to server2.
It says access denied....

Is there any way by which we can add networkcredential class object to
file.copy command, so that it works.

Any other help?
Shailesh G
 
M

Mr Newbie

OK, now I think I understand. If the account on the upload server (
Server1 ) is local account then you will need to add this file to a DOMAIN
GLOBAL Group and add the group with write permissions to the target
server\directory.

HTH Mr N.
 

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


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top