110,570
社区成员
发帖
与我相关
我的任务
分享
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (var di in drives)
Console.WriteLine("{0}:{1}", di.Name, di.DriveType);
public static void Run(string fileName, string arguments)
{
try
{
using (Process proc = new Process())
{
proc.StartInfo.FileName = fileName;
proc.StartInfo.Arguments = arguments;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
proc.Close();
}
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
}
}
//用这个创建连接:
Run("net.exe", @"use \\192.168.1.100\IPC$ 密码 /user:用户名");
//用这个创建映射
Run("net.exe", @"use Z: \\192.168.1.100\FolderName 密码 /user:用户名");