public void TestProcess() { //打开百度 //ProcessUtils.Execute(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "http://www.baidu.com"); //ProcessUtils.Shutdown(); string path = @"\\172.18.20.101"; string uid = @"luxshare\11000890"; string pwd = @"abc"; string errMsg = ""; var commandTexts = new List <string>() { $"net use {path} {pwd} /user:{uid}" }; if (ProcessUtils.ExecuteCMD(commandTexts)) { //FileInfo file=new FileInfo(""); var lstFiles = new List <FileInfo>(); var dir = new DirectoryInfo(path); foreach (var folder in dir.GetDirectories()) { foreach (var item in folder.GetFiles()) { if (item.Name.Contains("KPI")) //文件名要包含KPI 3个字 { lstFiles.Add(item); } } } var file = lstFiles.OrderByDescending(p => p.LastWriteTime).FirstOrDefault(); //日期最新的文件 Console.WriteLine("文件名:" + file.Name); //显示所有连接 //var result = ShareFileUtils.ShowConnect(); //Console.WriteLine("结果:" + result); } }