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;
            }
  • 相关阅读:
    使用ECMAScript 6 模块封装代码
    JavaScript生成一个不重复的ID
    利用setenv进行tomcat 内存设置
    使用Nginx、Nginx Plus防止服务器DDoS攻击
    【Nginx】实现负载均衡的几种方式
    一台Linux服务器可以负载多少个连接?
    Linux配置使用SSH Key登录并禁用root密码登录
    Spring JPA事务
    使用SVN钩子强制提交日志和限制提交文件类型
    RabbitMQ 初学及其深入学习推荐的一些文章
  • 原文地址:https://www.cnblogs.com/ylemzhang/p/1848120.html
Copyright © 2011-2022 走看看