0 Comments

// Create network drive mapping

System.Diagnostics.Process.Start(“net.exe”, @”use K: “”\\my.server.com\Websites\Mail“” /user:MyDomain\admin MySuperSecretPassword”).WaitForExit();

// Remove network drive mapping

System.Diagnostics.Process.Start(“net.exe”, @”use K: /delete”).WaitForExit();

One Reply to “Map network drive in C#

  1. Nice. I had old code that was using the Windows Script Host interop to map drives that was acting buggy after users switched from Windows 7 to 10. I tried your approach with much better success. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts