C# 删除文件夹

 /// <summary>
        /// 删除文件夹
        /// </summary>
        /// <param name="strPath">文件夹路径</param>
        /// <returns></returns>
        public static bool DelectDir(string strPath)
        {
            try
            {
                strPath = @strPath.Trim().ToString();// 清除空格

                if (Directory.Exists(strPath))
                {
                    Directory.Delete(strPath, true);
                }

                return true;// 成功
            }
            catch (Exception Exp) // 异常处理
            {
                System.Diagnostics.Debug.Write(Exp.Message.ToString());// 异常信息
                return false;// 失败
            }
        }

 

posted @ 2023-02-15 17:17  fulllove  阅读(37)  评论(0)    收藏  举报