C 刪除指定資料夾下N天及之前日誌檔案的方法

2022-10-04 02:12:09 字數 350 閱讀 9239

// 功能:刪除ndays天及之前的日誌檔案

// @ndays: 0-不刪除日誌,3-刪除3天及之前的日誌(保留今天、昨天、前天的日誌) .

void crecordlog::clearlog(uint ndays) // 刪除n天前的日誌

else // 遇到檔案

}} if(!findnextfile(hfind, &findfiledata))

break;

} findclose(hfind);

}}補充:上面被刪除的日誌檔案的檔名格式為:2011-02-08.log

本文標題: c++刪除指定資料夾下n天及之前日誌檔案的方法

本文位址:

刪除資料夾下30天之前的檔案,並指定檔案型別

刪除資料夾及其子資料夾內過期檔案 public void delfile string strfolderpath 判斷檔案日期是否小於今天,是則刪除 if feinfo.creationtime datetime.now.adddays 30 獲取資料夾下所有的檔案logs error direc...

c語言刪除linux指定資料夾下指定數量的檔案

include include include define maxlen 1024typedef struct file info file info struct list 定義乙個鍊錶頭部 static struct list list head null void rmfile char p...

c 刪除指定資料夾中今天之前的檔案

1 說明 使用directory類對指定資料夾下的今天或者更早日期之前的檔案進行刪除。2 資料夾路徑 string strfolderijjjaddgpath server.mappath excel directoryinfo dyinfo n程式設計客棧ew directoryinfo strf...