Swapnil Gupta
Swapnil Gupta

Reputation: 8941

how to map samba server drive to some local drive in C# using net use?

how to map samba server drive to some local drive in C# using net use ? And how to display them in Windows explorer like window ?

Any code snippet is highly appreciated. Thanks in Advance.

Upvotes: 0

Views: 599

Answers (1)

Michael Baker
Michael Baker

Reputation: 3434

I would recommend creating a batch file which contains the command you want to execute and then call this batch file from your C# application. This ensures if you need to change the net use command it is well encapsulated.

myBatchFile.cmd

net use z: \\server\resource

Application code

Process.Start(@"C:\myBatchFile.cmd");

You will need to add this using to your application.

using System.Diagnostics;

See here for more information on Process.Start:

Can you expand on "And how to display them in Windows explorer like window ?"

Upvotes: 2

Related Questions