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

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)

            {

            }

        }


你可能感兴趣的:(文件夹)