当前位置:网站首页>VC + + specified directory file output by time
VC + + specified directory file output by time
2020-11-08 09:40:00 【osc_4punxmqt】
function : Get all the files in a specified directory , Then save it in chronological order , Generally used for interface display , Or file list sorting function ...
// Sort
void CSubCameraControlDlg::FileArraySortbySystemTime(CStringArray& _arr)
{
int len = _arr.GetCount();
for(int i=0; i<len-1; i++)
{
int min=i;
for(int j=i+1; j<len; j++)
{
CString strtime1=GetFileLastModifyTime(_arr[min]);
CString strtime2=GetFileLastModifyTime(_arr[j]);
if(lstrcmpi(strtime1,strtime2)>0)
{
min=j;
}
}
CString t=_arr[min];
_arr[min]=_arr[i];
_arr[i]=t;
}
}
// Acquisition time
CString GetFileLastModifyTime(LPCTSTR strPath)
{
if (!::PathFileExists(strPath))
{
return _T("");
}
WIN32_FIND_DATA ffd ;
HANDLE hFind = FindFirstFile(strPath,&ffd);
if (INVALID_HANDLE_VALUE == hFind)
{
return _T("");
}
SYSTEMTIME st = {0};
FILETIME LocalFileTimel;
FileTimeToLocalFileTime(&ffd.ftLastWriteTime, &LocalFileTimel);
FileTimeToSystemTime(&LocalFileTimel, &st);
CString strFormat;
strFormat.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),st.wYear, st.wMonth, st.wDay,
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
FindClose(hFind);
return strFormat;
}
// Find the files in the directory
void CSubCameraControlDlg::FindDirFile(CString strdir, CStringArray& _arr)
{
TCHAR szPath[MAX_PATH] = {0};
::GetModuleFileName(NULL, szPath, MAX_PATH);
::PathRemoveFileSpec(szPath);
CString strffmpegPath;
::PathCombine(strffmpegPath.GetBufferSetLength(MAX_PATH), szPath, strdir);
// CString filepath = _T("/path/to/folder/");
CString filename = _T("");
CString fullname = _T("");
CFileFind find;
BOOL IsFind = find.FindFile(strffmpegPath + _T("/*.*"));
while (IsFind)
{
IsFind = find.FindNextFile();
if (find.IsDots())
{
continue;
}
else
{
filename = find.GetFileName();
fullname = strffmpegPath + filename;
_arr.Add(fullname);
}
}
}
版权声明
本文为[osc_4punxmqt]所创,转载请带上原文链接,感谢
边栏推荐
- AMD Zen3首发评测:频率超5GHz,IPC提升不止19%,这次真的Yes了 - 知乎
- Tiktok live monitoring Api: random recommendation
- 5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
- 函数周期表丨筛选丨值丨SELECTEDVALUE - 知乎
- print( 'Hello,NumPy!' )
- Windows下子系统Ubuntu安装
- SQL Server 2008R2 18456错误解决方案
- Flink的sink实战之一:初探
- 2020-11-05
- Adobe Prelude /Pl 2020软件安装包(附安装教程)
猜你喜欢
PX4添加新的应用
Mate 40 series launch with Huawei sports health service to bring healthy digital life
软件测试就是这么回事?!
Recommend an economic science video, very valuable!
5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
ASP.NET A complete solution based on exception handling in MVC
Ulab 1.0.0 release
阅读心得:FGAGT: Flow-Guided Adaptive Graph Tracking
python_ scrapy_ Fang Tianxia
数据科学面试应关注的6个要点
随机推荐
Unparseable date: 'mon Aug 15 11:24:39 CST 2016', time format conversion exception
FORTRAN77从文件中读入若干数据并用heron迭代公式开方
More than 50 object detection datasets from different industries
python学习 day1——基础学习
“1024”征文活动结果新鲜出炉!快来看看是否榜上有名?~~
Unparseable date: 'Mon Aug 15 11:24:39 CST 2016',时间格式转换异常
python_ scrapy_ Fang Tianxia
双向LSTM在时间序列异常值检测的应用
归纳一些比较好用的函数
iOS 学习笔记二【cocopods安装使用和安装过程中遇到的问题及解决办法】【20160725更新】
VC++指定目录下文件按时间排序输出
PerconaXtraDBCluster8.0 最详尽用法指南
Julia 是如何风靡起来的?
Windows subsystem Ubuntu installation
sed之查找替换
Oops, the system is under attack again
技术人员该如何接手一个复杂的系统?
游戏优化性能杂谈(十一) - 知乎
PCR and PTS calculation and inverse operation in TS stream
That's what software testing is all about?!