IDirectoryOperator.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. namespace XGame.Framework.FileSystem
  2. {
  3. /// <summary>
  4. /// 文件夹操作接口
  5. /// </summary>
  6. public interface IDirectoryOperator
  7. {
  8. /// <summary>
  9. /// 新建文件夹(逐级新建)
  10. /// </summary>
  11. /// <param name="fullDirectory">文件夹全路径</param>
  12. /// <returns>True: 新建成功; False: 新建失败</returns>
  13. bool Mkdir(string fullDirectory);
  14. /// <summary>
  15. /// 删除文件夹
  16. /// </summary>
  17. /// <param name="fullDirectory">文件夹全路径</param>
  18. /// <param name="includeSelf">删除自身</param>
  19. /// <returns>True: 删除成功; False: 删除失败;</returns>
  20. bool Delete(string fullDirectory, bool includeSelf = true);
  21. /// <summary>
  22. /// 文件夹是否存在
  23. /// </summary>
  24. /// <param name="fullDirectory">文件夹全路径</param>
  25. /// <returns>True: 存在; False: 不存在;</returns>
  26. bool Exist(string fullDirectory);
  27. /// <summary>
  28. /// 复制(含子文件夹和子文件)
  29. /// </summary>
  30. /// <param name="source">源文件夹</param>
  31. /// <param name="destination">目标文件夹(清空)</param>
  32. /// <returns>True: 复制成功; False: 复制失败</returns>
  33. bool Copy(string source, string destination, bool overwrite);
  34. /// <summary>
  35. /// 获取文件夹名
  36. /// </summary>
  37. /// <param name="fullDirectory">文件夹全路径</param>
  38. /// <returns>文件夹名(最后一个"/")</returns>
  39. string GetDirectoryName(string fullDirectory);
  40. /// <summary>
  41. /// 获取文件夹下的所有文件或者文件夹的路径
  42. /// </summary>
  43. /// <param name="fullDirectory">文件夹全路径</param>
  44. /// <returns></returns>
  45. string[] GetFileSystemEntries(string fullDirectory);
  46. /// <summary>
  47. /// 异步删除文件夹
  48. /// </summary>
  49. /// <param name="fullDirectory">完整路径</param>
  50. /// <param name="includeSelf">是否包含自身</param>
  51. /// <returns></returns>
  52. IDeleteDirectoryAsync DeleteAsync(string fullDirectory, bool includeSelf = true);
  53. /// <summary>
  54. /// 重命名
  55. /// </summary>
  56. /// <param name="from"></param>
  57. /// <param name="to"></param>
  58. /// <returns></returns>
  59. bool Rename(string from, string to);
  60. /// <summary>
  61. /// 获取文件夹下指定拓展名文件
  62. /// </summary>
  63. /// <param name="fullDirectory">根文件夹全路径</param>
  64. /// <param name="extension">拓展名(".xxx")</param>
  65. /// <param name="recursion">递归</param>
  66. /// <returns></returns>
  67. string[] GetFiles(string fullDirectory, string extension, bool recursion = true);
  68. }
  69. }