Re: Copy file to remote PC
- From: alexia.bee@xxxxxxxxx
- Date: Thu, 10 Apr 2008 00:03:27 -0700 (PDT)
On Apr 10, 1:26 am, "Willy Denoyette [MVP]"
<willy.denoye...@xxxxxxxxxx> wrote:
<alexia....@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.
Hi all and thanks for the reply.
What is exactly the "sharenane"? is it the user name?
if I don't use "net use", where do i put username and password (and
domain if any) in the string when I copy the file?
thanks.
.
- Follow-Ups:
- Re: Copy file to remote PC
- From: Willy Denoyette [MVP]
- Re: Copy file to remote PC
- References:
- Copy file to remote PC
- From: alexia . bee
- Re: Copy file to remote PC
- From: alexia . bee
- Re: Copy file to remote PC
- From: Willy Denoyette [MVP]
- Copy file to remote PC
- Prev by Date: Passing Data in MDI Parent form and Child Form
- Next by Date: Datareader(simple)
- Previous by thread: Re: Copy file to remote PC
- Next by thread: Re: Copy file to remote PC
- Index(es):
Relevant Pages
|