当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- ASP.NET A complete solution based on exception handling in MVC
- Shiyou's numerical analysis assignment
- An error occurred while starting the kernel was successfully resolved
- python_ scrapy_ Fang Tianxia
- 哔哩哔哩常用api
- Littlest jupyterhub| 02 using nbgitpuller to distribute shared files
- [data structure Python description] use hash table to manually implement a dictionary class based on Python interpreter
- 【总结系列】互联网服务端技术体系:高性能之数据库索引
- Littlest JupyterHub| 02 使用nbgitpuller分发共享文件
- Search and replace of sed
猜你喜欢

iOS上传App Store报错:this action cannot be completed -22421 解决方案

How does spotify drive data-driven decision making?

ArrayList源码分析

分布式共识机制

Simple use of future in Scala

模板链表类学习

Spotify是如何推动数据驱动决策的?

Fgagt: flow guided adaptive graph tracking

What details does C + + improve on the basis of C

狗狗也能操作无人机!你没看错,不过这其实是架自动驾驶无人机 - 知乎
随机推荐
IOS upload app store error: this action cannot be completed - 22421 solution
That's what software testing is all about?!
What is the difference between vivoy73s and vivoy70s
OSChina 周日乱弹 —— 之前呢,我一直以为自己是个……
M-end software product design considerations - Zhihu
Test requirements for MIC certification of Bluetooth 2.4G products in Japan
归纳一些比较好用的函数
分布式共识机制
Seven features of Python 3.9
软件测试就是这么回事?!
技术人员该如何接手一个复杂的系统?
laravel8更新之速率限制改进
Six key points of data science interview
阅读心得:FGAGT: Flow-Guided Adaptive Graph Tracking
Flink的sink实战之一:初探
python_ scrapy_ Fang Tianxia
ArrayList源码分析
抖音直播监控Api:随机推荐
i5 1135g7和i5 1035g1参数对比区别大吗? 哪个好
vivoY73s和vivoY70s的区别 vivoY73s和vivoY70s哪个值得入手