清空文件夹里面的所有文件和文件夹

private void deletefileOrDic(System.IO.DirectoryInfo path)
        {
            try
            {
                foreach (System.IO.DirectoryInfo d in path.GetDirectories())
                {
                    d.Delete(true);
                }
                foreach (System.IO.FileInfo f in path.GetFiles())
                {
                    f.Delete();
                }
            }
            catch (Exception ex)
            {
            }
        }


posted @ 2013-07-12 19:36  爱生活,爱编程  阅读(373)  评论(0编辑  收藏  举报