關於目錄的 DOS Command
1.Server目錄
把Server分享的目錄變成我的 Z 磁碟機
net use Z:"\\server\path\" password /user:"username"
把虛擬的Z 磁碟機刪除
net use z: /d
2.本機目錄
把d:\test 目錄變成本機Z 磁碟機
subst z: d:\test
把虛擬的Z 磁碟機刪除
subst z: /d
如果想要寫程式的話可以參考下面
[DllImport("Kernel32.dll")]
public static extern bool DefineDosDevice(int dwFlags, string lpDeviceName, string lpTargetPath);
public static bool MapDevice(string strDeviceName, string strTargetPath)
{
return DefineDosDevice(0, strDeviceName, strTargetPath);
}
public static bool UnMapDevice(string strDeviceName)
{
return DefineDosDevice(3, strDeviceName, "");
}
private void button1_Click(object sender, EventArgs e)
{
MapDevice("B:", @"D:\test");
}
private void button2_Click(object sender, EventArgs e)
{
UnMapDevice("B:");
}