发布网友 发布时间:2022-04-23 14:51
共1个回答
热心网友 时间:2023-10-03 03:06
try { ManagementScope ms = new ManagementScope(@"\\10.19.96.215"); ConnectionOptions conn = new ConnectionOptions(); conn.Username = "用户名"; conn.Password = "密码"; ms.Options = conn; ms.Connect(); DirectoryInfo di = new DirectoryInfo(@"\\192.168.8.12\c$\gongxiang\"); StringBuilder sb = new StringBuilder(); foreach(DirectoryInfo subDIR in di.GetDirectories()) { sb.Append(subDIR.Name + "\n\r"); } MessageBox.Show("get\n\r" + sb.ToString()); } catch(Exception ex) { MessageBox.Show(ex.Message); }