/// <summary>
        /// 文件重命名
        /// </summary>
        /// <param name="fInfo"></param>
        /// <param name="newPath"></param>
        public static bool RenameFile(FileInfo fInfo,string newPath)
        {
            string fullName = String.Format(LOG_FULLNAME, "RenameFile");
            Dictionary<string, string> logDic = new Dictionary<string, string>();
            logDic.Add("newPath", newPath);
            LogMessageHelper.LogerMessage(LogMessageLevel.Info, fullName, string.Empty, "文件重命名", logDic);            
            try
            {
                fInfo.MoveTo(newPath);
            }
            catch (Exception ex)
            {
                LogMessageHelper.LogerMessage(LogMessageLevel.Error, fullName, string.Empty, "文件重命名错误", logDic, ex);
                return false;
            }
            return true;
        }

        /// <summary>
        /// 目录重命名
        /// </summary>
        /// <param name="fInfo"></param>
        /// <param name="newPath"></param>
        public static bool RenameDir(DirectoryInfo di, string newPath)
        {
            string fullName = String.Format(LOG_FULLNAME, "RenameDir");
            Dictionary<string, string> logDic = new Dictionary<string, string>();
            logDic.Add("newPath", newPath);
            LogMessageHelper.LogerMessage(LogMessageLevel.Info, fullName, string.Empty, "目录重命名", logDic);
            try
            {
                di.MoveTo(newPath);
            }
            catch (Exception ex)
            {
                LogMessageHelper.LogerMessage(LogMessageLevel.Error, fullName, string.Empty, "目录重命名错误", logDic, ex);
                return false;
            }
            return true;
        }

相关文章:

  • 2022-01-29
  • 2022-12-23
  • 2022-03-10
  • 2021-11-17
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-10-16
  • 2022-02-10
相关资源
相似解决方案