删除文件夹

实现效果:

  

知识运用:

  DirectoryInfo类的Delete方法

    public override voie Delete()    //文件夹非空会报错

     public void Delete (bool  recursive)    //是否递归删除

实现代码:

        private void button2_Click(object sender, EventArgs e)
        {
            DirectoryInfo Dinfo = new DirectoryInfo(textBox1.Text);
            Dinfo.Delete(true);                                       //删除文件夹中的所有内容
            MessageBox.Show("文件夹删除成功");
        }

  

原文地址:https://www.cnblogs.com/feiyucha/p/10241758.html