using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BaiduYunBeiFen { public class PybyClass { public List CheckPathFile(string YunPath) { List Result = new List(); string OutYunPath; ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = "cmd.exe"; processStartInfo.Arguments = YunPath; processStartInfo.RedirectStandardOutput = true; processStartInfo.UseShellExecute = false; processStartInfo.CreateNoWindow = true; // 创建并启动Process对象 Process process = new Process(); process.StartInfo = processStartInfo; process.Start(); // 读取CMD输出 string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); process.Dispose(); string[] Message = output.Split(Environment.NewLine); Result = ReMoveWarnMessage(Message.ToList(),out OutYunPath); return Result; } public List ReMoveWarnMessage(List FileList,out string YunPath) { List Result = new List(FileList); List WarnList = new List() { "", "Files with non-ASCII names may not be handled correctly.", "You should set your System Locale to 'UTF-8'.", "Current locale is 'cp65001'" }; foreach (string File in FileList) { if (WarnList.Exists(t => File.Contains(t))) { Result.Remove(File); } } YunPath = Result[0]; Result.Remove(Result[0]); return Result; } } }