FileCore.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "duilib.h"
  4. #include <Shlwapi.h>
  5. #include "KeyVar.h"
  6. class FileCore
  7. {
  8. #pragma region 文件
  9. public:
  10. static bool IsExistTheFileW(wstring filePath);
  11. static bool IsExistProductAppPath();//安装后的产品应用程序绝对路径
  12. static bool SourceFileMoveToDestionPath(wstring sourceFile,wstring destPath);//
  13. #pragma endregion
  14. };
  15. class FolderCore
  16. {
  17. #pragma region 文件夹
  18. public:
  19. static wstring GetNewSaveFolder(wstring saveFilePath, wstring oldchar, wstring newchar);
  20. static wstring GetOrCreateFolderPath(wstring saveFilePath);
  21. static bool IsExistTheFolderW(wstring folderPath);
  22. //是否存在根目录
  23. static bool IsRootDirectoryW(wstring folderPath);
  24. //在根目录下预设子文件夹路径,此时未创建子文件夹
  25. static wstring AddSubFolderFromRootDirW(wstring folderPath, wstring newSubFolderName);
  26. //文件夹选择器
  27. static wstring FolderBrowser(HWND m_hWnd);
  28. /// <summary>
  29. /// 获取系统路径
  30. /// </summary>
  31. /// <param name="csidl">系统指定的路径名称,例如user\\kdan\\文档</param>
  32. /// <returns>系统路径</returns>
  33. static wstring SetSHGetFolderPath(_In_ int csidl);
  34. static void InitAppTempPath();
  35. /// <summary>
  36. /// 获取缓存路径,并在缓存路径下创建一个文件夹
  37. /// </summary>
  38. /// <returns>如果获取不到缓存路径,就更换为文档路径;若两个路径都获取不到,就返回空字符串</returns>
  39. static wstring GetAppTempPath();
  40. static void ClearAllTempFolder();
  41. static void RemoveFolder(wstring path);
  42. #pragma endregion
  43. };
  44. class DiskCore
  45. {
  46. public:
  47. //磁盘空间是否充足
  48. static bool IsEnoughDisk(wstring smPath);
  49. //系统盘的盘符
  50. static wstring GetSystemDriveLetter();
  51. //路径长度是否合理,isDowndPackgeBefore为是否在下载安装包之前判断(因为安装包文件名也有长度)
  52. static bool IsMeetInstallPathMaxLength(bool isDowndPackgeBefore);
  53. };