123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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<string> CheckPathFile(string YunPath)
- {
- List<string> Result = new List<string>();
- 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<string> ReMoveWarnMessage(List<string> FileList,out string YunPath)
- {
- List<string> Result = new List<string>(FileList);
- List<string> WarnList = new List<string>()
- {
- "<W>",
- "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;
- }
- }
- }
|