FileHelper.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Oreo.VersionUpdate.Commons;
  2. using Oreo.VersionUpdate.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Y.Utils.IOUtils.PathUtils;
  10. using Y.Utils.IOUtils.TxtUtils;
  11. namespace Oreo.VersionUpdate.Helpers
  12. {
  13. public class FileHelper
  14. {
  15. public static void Clean(VersionModel vm)
  16. {
  17. //清理临时文件夹
  18. if (Directory.Exists(R.Paths.Temp))
  19. {
  20. try { Directory.Delete(R.Paths.Temp, true); } catch { }
  21. }
  22. //清理指定文件
  23. var cleanFile = vm.FileList.Where(x => x.IsClean == true);
  24. foreach (var file in cleanFile)
  25. {
  26. string fff = DirTool.IsDriver(file.LocalFile) ? file.LocalFile : R.Paths.ProjectRoot + file.LocalFile;
  27. if (File.Exists(fff))
  28. {
  29. try { File.Delete(fff); } catch { }
  30. }
  31. }
  32. }
  33. }
  34. }