Monday, April 25, 2011

C# Mapping a network drive

C# can map a network drive by calling OS commands [1] or using native win32 API [2].

The code below is from [1]:

System.Diagnostics.Process.Start("net.exe", "use K: \\Server\URI\\path\\here");
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = "C:\\application.exe";
psi.WorkingDirectory = "K:\\working\\directory";
psi.WindowStyle = System.Diagnostics.
ProcessWindowStyle.Maximized;
System.Diagnostics.Process p =
System.Diagnostics.Process.Start(psi);

[1] http://forum.codecall.net/c-programming/1119-c-mapping-network-drive.html
[2] http://bytes.com/topic/c-sharp/answers/812115-mapping-network-drive-c

No comments:

Blog Archive

Followers