Moving a file from one server to another
-
Hello, I am trying to implement an asp.net page which will move a file from a folder on the web server to another server. I have the following code: File.Move("E:\temp\image.gif", "\\dnssvr1\Ad\image.gif"); When I try this, I am getting some sort of error about a username and password. Is there a particular place where I have to set a username and password? Do I need to specify the path to the destination differently? Thanks, RC
-
Hello, I am trying to implement an asp.net page which will move a file from a folder on the web server to another server. I have the following code: File.Move("E:\temp\image.gif", "\\dnssvr1\Ad\image.gif"); When I try this, I am getting some sort of error about a username and password. Is there a particular place where I have to set a username and password? Do I need to specify the path to the destination differently? Thanks, RC
This means you (or whatever credentials the app is running under) don't have permissions to the remote resource. Either make sure your domain account has appropriate permissions to that directory (or, in some cases, that a local user with exactly the same username and password exists on both machines - such as on a workgroup), or use impersonation for someone that does. See
WindowsIdentity
for easy impersonation in .NET.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----