PC Review


Reply
Thread Tools Rate Thread

Copy files over a network share

 
 
John Varouxis
Guest
Posts: n/a
 
      26th Jul 2005
Hi all,

I want to copy files residing in a network shared folder, but I have to pass
different user credentials than the executing user. How can I accomplish
this. The System.IO.File.Copy overloaded methods don't accept credentials in
any form.

Thanx in advance,
Yannis


 
Reply With Quote
 
 
 
 
Goran Sliskovic
Guest
Posts: n/a
 
      26th Jul 2005

"John Varouxis" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi all,
>
> I want to copy files residing in a network shared folder, but I have to

pass
> different user credentials than the executing user. How can I accomplish
> this. The System.IO.File.Copy overloaded methods don't accept credentials

in
> any form.
>
> Thanx in advance,
> Yannis
>


Hi,
I think you'll have to use native API to accomplish this. You have to call
LogonUser API and then impersonate. There is a sample in MSDN, check
WindowsIdentity.Impersonate Method in System.Security.Principal namespace.

I have once used WNetUseConnection API to map drive with different
credentials and then access it (as an alternative method).

Regards,
Goran



 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      26th Jul 2005

"John Varouxis" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi all,
>
> I want to copy files residing in a network shared folder, but I have to
> pass
> different user credentials than the executing user. How can I accomplish
> this. The System.IO.File.Copy overloaded methods don't accept credentials
> in
> any form.
>
> Thanx in advance,
> Yannis
>
>


The simplest is to establish a network session with the share (using net use
....) from your logon session, no special code needed. This works only if
your applications runs in the same logon session of course.

Willy.




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista can't copy files from network share on XPPro MDaniel Windows Vista Networking 24 30th Jan 2008 02:18 PM
How to copy files across network without using network share =?Utf-8?B?U2Vhbk1hYw==?= Microsoft VB .NET 3 22nd Jun 2007 05:51 PM
Copy files across network share using different credentials jonoaustin@gmail.com Microsoft VB .NET 0 28th Aug 2006 08:06 AM
How to share/copy files via my wireless network? Strangiato Windows XP General 1 29th Dec 2003 06:49 PM
How to share/copy files via my wireless network? Strangiato Windows XP Networking 0 29th Dec 2003 10:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:27 AM.