PybyClass.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace BaiduYunBeiFen
  9. {
  10. public class PybyClass
  11. {
  12. public List<string> CheckPathFile(string YunPath)
  13. {
  14. List<string> Result = new List<string>();
  15. string OutYunPath;
  16. ProcessStartInfo processStartInfo = new ProcessStartInfo();
  17. processStartInfo.FileName = "cmd.exe";
  18. processStartInfo.Arguments = YunPath;
  19. processStartInfo.RedirectStandardOutput = true;
  20. processStartInfo.UseShellExecute = false;
  21. processStartInfo.CreateNoWindow = true;
  22. // 创建并启动Process对象
  23. Process process = new Process();
  24. process.StartInfo = processStartInfo;
  25. process.Start();
  26. // 读取CMD输出
  27. string output = process.StandardOutput.ReadToEnd();
  28. process.WaitForExit();
  29. process.Dispose();
  30. string[] Message = output.Split(Environment.NewLine);
  31. Result = ReMoveWarnMessage(Message.ToList(),out OutYunPath);
  32. return Result;
  33. }
  34. public List<string> ReMoveWarnMessage(List<string> FileList,out string YunPath)
  35. {
  36. List<string> Result = new List<string>(FileList);
  37. List<string> WarnList = new List<string>()
  38. {
  39. "<W>",
  40. "Files with non-ASCII names may not be handled correctly.",
  41. "You should set your System Locale to 'UTF-8'.",
  42. "Current locale is 'cp65001'"
  43. };
  44. foreach (string File in FileList)
  45. {
  46. if (WarnList.Exists(t => File.Contains(t)))
  47. {
  48. Result.Remove(File);
  49. }
  50. }
  51. YunPath = Result[0];
  52. Result.Remove(Result[0]);
  53. return Result;
  54. }
  55. }
  56. }