Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

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

        }

 

Monday, November 5, 2012

Calculating Date Difference in C#

c# - Calculate difference between two Dates

Solution:

  
int day=0;
 DateTime d1 = Convert.ToDateTime(yourdate);
  DateTime d2 = System.DateTime.Now;
  day = (d1 - d2).Days;