按时间参数搜索文件 [英] Search for file by time parameters
本文介绍了按时间参数搜索文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试搜索最近5秒钟内在硬盘驱动器上创建的文件.到目前为止,我一直在搜索,但仍然不知所措.任何帮助表示赞赏.谢谢你.
ifstream ifile(*.*);
如果(ifile){
int myfile
myFile = 1 ;
其他
myfile = 0 ;
}
这是在Windows中.刚变得更强硬.看来文件时间和系统时间是两个不同的事物,并且系统时间需要转换为文件时间!
解决方案
此^ ]应该是一个很好的起点.
它还显示了如何使用FILETIME
和SYSTEMTIME
.我需要更改或改善的任何内容,请放心.谢谢.
time_t currentTime; 类 = " >时间(¤tTime); // 当前时间 结构 tm * ptm = localtime(¤tTime); int tm_sec; // 0到59 int tm_min; // 0到59 int tm_hour; // 0到23 int tm_mday; // 1到31 int tm_mon; // 0到11 int tm_year; // int tm_wday; // 0到6 int tm_yday; // 0到365 int tm_isdst; // 0到1 字符 * tm_zone; // 时间区域 int tm_gmtoff; 字符 tod; tod = tm_sec; 如果(tod< = time_t- 5 tm_sec) 删除(" highlight " > *.txt 删除");
I''m trying to search for a file created somewhere on my hard drive within the last 5 seconds. I have this so far and have been googling, but still at loss. Any help is appreciated. Thnak you.
ifstream ifile(*.*);
if (ifile) {
int myfile
myFile = 1;
else
myfile = 0;
}
This is in windows. Just got tougher. It seems filetime and systemtime are two different things and systemtime needs to be converted to filetime!
解决方案
This example code[^] should be a good starting point.
It also shows how to useFILETIME
andSYSTEMTIME
.
Came up with this, However some input would be nice! Anything that I have to change or make better please feel free. Thank you.
time_t currentTime; class="highlight">time (¤tTime); // current time struct tm * ptm= localtime(¤tTime); int tm_sec; // 0 to 59 int tm_min; // 0 to 59 int tm_hour; // 0 to 23 int tm_mday; // 1 to 31 int tm_mon; // 0 to 11 int tm_year; // int tm_wday; // 0 to 6 int tm_yday; // 0 to 365 int tm_isdst; // 0 to 1 char *tm_zone; // time zone int tm_gmtoff; char tod; tod = tm_sec; if ( tod <= time_t - 5 tm_sec ) remove ( "">*.txt to delete" );
这篇关于按时间参数搜索文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文