zoukankan      html  css  js  c++  java
  • c#文件,目录重命名

    /// <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;
            }
  • 相关阅读:
    UI、JS框架----Bootstrap、Metro
    重构—改善既有代码的设计4——构筑测试体系
    重构—改善既有代码的设计3——代码的坏味道
    正则匹配-URL-域名
    pgAdmin的数据恢复
    重构—改善既有代码的设计2
    重构—改善既有代码的设计1
    Levenshtein Distance,判断字符串的相似性
    最大匹配字符串LCS,The Longest Common Substring
    email
  • 原文地址:https://www.cnblogs.com/ylemzhang/p/1848120.html
Copyright © 2011-2022 走看看