The "right" way to do this is probably to grant the principle the proper
access rights, however if you've ruled that out and are willing to
accept the security implications involved, you could issue a "net use"
command via System.Diagnostics.Process.Start(...) prior to trying to
copy the file. You can find the syntax for it by typing:
net use /?
at the command line. I believe that once it has been issued the system
will cache the access rights (wrong term... right concept) and allow
access to the machine for subsequent calls. You'll have to try it out
to know for sure but I think this just might do it.
Anyone know of another way to do this that doesn't feel so "wrong?"
Have A Better One!
John M Deal, MCP
Necessity Software
BLiTZWiNG wrote:
How does one copy a file to a UNC path and include authentication?
My current code is:
System.IO.File.Copy(@"c:\picture.jpg", @"\\server\share\picture.jpg");
Of course I just get a login failed for this, as I don't know how to
transmit authentication information with the request.
Anyone know how to do this?