/// <summary>
        /// 获取上级文件夹路径
        /// </summary>
        /// <param name="path">路径</param>
        /// <param name="degree">级数</param>
        /// <returns></returns>
        private string GetParentDirectory(string path, int degree)
        {
            DirectoryInfo pathInfo = new DirectoryInfo(path);
            string newPath = pathInfo.Parent.FullName;

            for (int i = 0; i < degree; i++)
            {
                pathInfo = new DirectoryInfo(newPath);
                newPath = pathInfo.Parent.FullName;
            }
            return newPath;
        }

 

相关文章:

  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-03-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-06-28
相关资源
相似解决方案