zoukankan      html  css  js  c++  java
  • C# 清空文件夹

       /// <summary>
            /// 清空文件夹
            /// </summary>
            /// <param name="dir"></param>
            public void DeleteFolder(string dir)
            {
                foreach (string d in Directory.GetFileSystemEntries(dir))
                {
                    if (File.Exists(d))
                    {
                        FileInfo fi = new FileInfo(d);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                            fi.Attributes = FileAttributes.Normal;
                        File.Delete(d);//直接删除其中的文件 
                    }
                    else
                    {
                        DirectoryInfo d1 = new DirectoryInfo(d);
                        if (d1.GetFiles().Length != 0)
                        {
                            DeleteFolder(d1.FullName);////递归删除子文件夹
                        }
                        Directory.Delete(d);
                    }
                }
            }

  • 相关阅读:
    C和C++的不同点
    音频质量评价指标
    常用函数整理
    Subband Decomposition
    Stability Analysis of Algorithms
    Time Frequency (T-F) Masking Technique
    雅克比(Jacobi)方法
    寒假3
    寒假作业二
    寒假 2
  • 原文地址:https://www.cnblogs.com/yisheng/p/2833246.html
Copyright © 2011-2022 走看看