RelativePathThread.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using GeekDesk.Constant;
  2. using GeekDesk.Util;
  3. using GeekDesk.ViewModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. namespace GeekDesk.MyThread
  13. {
  14. public class RelativePathThread
  15. {
  16. public static void MakeRelativePath()
  17. {
  18. new Thread(() =>
  19. {
  20. Thread.Sleep(1000);
  21. ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
  22. string myExePath = Constants.APP_DIR + "GeekDesk.exe";
  23. foreach (MenuInfo mi in menuList)
  24. {
  25. ObservableCollection<IconInfo> iconList = mi.IconList;
  26. foreach (IconInfo icon in iconList)
  27. {
  28. icon.RelativePath_NoWrite = FileUtil.MakeRelativePath(myExePath, icon.Path);
  29. }
  30. }
  31. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  32. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
  33. }).Start();
  34. }
  35. }
  36. }