Re: Copy file to remote PC
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 10 Apr 2008 00:26:05 +0200
<alexia.bee@xxxxxxxxx> wrote in message news:808af84f-c81b-46b8-9c59-7e587412b6fc@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am afraid that file.copy or permission access is good for copying
file manually. it is not the same
if copying file prorammatically.
I saw there is a function called UserLogOm() but it is not good for
RPC in the domain.
Don't know what RPC has to do with this.
You need to run your program in a domain account with appropriate privileges to access the remote share.
In your program all you need to do is specify the UNC path of the remote file, something like this:
File.Copy("localfile", @"\\servername\sharename\dir\dir\file");
If you don't run in a domain account, you will have to create a logon session (LogonUser() ) and impersonate a domain account.
Another viable option is to create a session with the remote server/share using the "net use ..." command line utility.
For instance when you issue following command (from the command line or by code):
net use \\remServer\someShare myDomainPwd /user:myDomain\myDomainAccount
you will be able to copy a local file to the remote share like this:
...
File.Copy("somefile.txt", @"\\remServer\someShare\someremotefile.txt");
....
Willy.
.
- Follow-Ups:
- Re: Copy file to remote PC
- From: alexia . bee
- Re: Copy file to remote PC
- References:
- Copy file to remote PC
- From: alexia . bee
- Re: Copy file to remote PC
- From: alexia . bee
- Copy file to remote PC
- Prev by Date: Visual Studio 2008 and code snipIts
- Next by Date: Re: Globally capturing keyboard events for a WinForm application?
- Previous by thread: Re: Copy file to remote PC
- Next by thread: Re: Copy file to remote PC
- Index(es):
Relevant Pages
|