当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 高并发,你真的理解透彻了吗?
- 阅读心得:FGAGT: Flow-Guided Adaptive Graph Tracking
- ts流中的pcr与pts计算与逆运算
- Macquarie Bank drives digital transformation with datastex enterprise (DSE)
- C++在C的基础上改进了哪些细节
- 架构师(2020年11月)
- python_ scrapy_ Fang Tianxia
- Cloud alibabab notes come out, the whole network detailed explanation only this one hand is slow
- Recommend an economic science video, very valuable!
- nvm
猜你喜欢

print( 'Hello,NumPy!' )

ASP.NET A complete solution based on exception handling in MVC

Test requirements for MIC certification of Bluetooth 2.4G products in Japan

Swiper window width changes, page width height changes lead to automatic sliding solution

“智能5G”引领世界,数位智能网优+5G能带来什么?

Littlest JupyterHub| 02 使用nbgitpuller分发共享文件

技术人员该如何接手一个复杂的系统?

数据科学面试应关注的6个要点

糟糕,系统又被攻击了

Experience the latest version of erofs on Ubuntu
随机推荐
PerconaXtraDBCluster8.0 最详尽用法指南
Cloud Alibabab笔记问世,全网详解仅此一份手慢无
iOS上传App Store报错:this action cannot be completed -22421 解决方案
Cloud alibabab notes come out, the whole network detailed explanation only this one hand is slow
攻防世界之web新手题
[data structure Python description] use hash table to manually implement a dictionary class based on Python interpreter
解决Safari浏览器下载文件文件名称乱码的问题
临近双11,恶补了两个月成功拿下大厂offer,跳槽到阿里巴巴
PCIe 枚举过程
Littlest JupyterHub| 02 使用nbgitpuller分发共享文件
Julia 是如何风靡起来的?
个人目前技术栈
Solve Safari browser download file name garbled problem
Search and replace of sed
2020-11-05
软件测试就是这么回事?!
Rust: command line parameter and environment variable operation
Flink的sink实战之一:初探
Oschina plays on Sunday - before that, I always thought I was a
麦格理银行借助DataStax Enterprise (DSE) 驱动数字化转型