#region regularly delete directory files///<summary>///Time Delete directory files
Northeasttycoon//</summary>//<param name= "Strparatime" > define as INT type variable according to the parameter appropriate </PARAM> ; public void Deleterecfiles (string strparatime) {
Get file path string path = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "backupmessageinfo");
Gets the number of days to delete DateTime _dtnow = DateTime.Parse (DateTime.Today.ToString ("Yyyy-mm-dd")). AddDays (-convert.toint32 (strparatime)); Time is configurable//DateTime _dtnow = DateTime.Parse ("2016-7-26"); if (directory.exists (path)) {DirectoryInfo _directoryinfo = new DirectoryInfo (path); directoryinfo[] _dicinfolist = _directoryinfo.getdirectories (); foreach (DirectoryInfo dicinfo in _dicinfolist) {int inayibutime = Datetime.compare (_dt Now, DateTime.Parse (Dicinfo.name)); if (0 < Inayibutime) {Dicinfo.delete (true); }}} #endregion
C # Deletes a directory and all of its files based on read configuration information