Friday, November 30, 2012

How To Delete All Files From Folder In Asp.net C#

solution

  var path = Server.MapPath("~/temp");

        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path.ToString());

        System.IO.FileInfo[] rgFiles = di.GetFiles("*.xml");

        foreach (System.IO.FileInfo fi in rgFiles)

        {

            fi.Delete();

            // Delete the files here

        }

 

No comments:

Post a Comment