How to copy files to a password protected shared folder on another server

Posted on 2012-03-22
Last Modified: 2012-03-27

I can manually in Windows 7: Type in Run: \\<ip address>\sharedFolder, type in my username and password, a folder opens in Windows Explorer, I can then copy a file to the shared folder.

How can I do this in C#? I can do a File.Copy() but I can't get around the part about specifying the username/password.

Question by:DanTartaglia
  • 2
LVL 77

Assisted Solution

arnold earned 167 total points
ID: 37755762
Not sure about c#, what about powershell? There are many examples including vbscript.
Within c# you would run net use to map a drive to a unc

Accepted Solution

netjgrnaut earned 333 total points
ID: 37757030
...or run NET USE to connect to \\ServerName\IPC$ with a user and password specified.  Then you can write to the \\ServerName\Share of choice without having to map a drive.

Author Comment

ID: 37757104
Thanks to both of you. I'll use the NET USE command one way or the other.

Assisted Solution

netjgrnaut earned 333 total points
ID: 37757175

You might find that discussion helpful, if you want to go the C# route...

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FTP logging 2 66
Perform a system restore through Safe Mode with command prompt 3 121
How to install USMT 11 119
Access Based Enumeration on by default for all Network Shares 3 113
Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question