当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Insight -- the application of sanet in arbitrary style transfer
- ASP.NET MVC下基于异常处理的完整解决方案
- 推荐一部经济科普视频,很有价值!
- 临近双11,恶补了两个月成功拿下大厂offer,跳槽到阿里巴巴
- nvm
- What details does C + + improve on the basis of C
- Visual studio 2015 unresponsive / stopped working problem resolution
- Review the cloud computing application scenarios you didn't expect (Part 1)
- 双向LSTM在时间序列异常值检测的应用
- Wechat nickname Emoji expression, special expression causes the list not to be displayed, export excel error report and other problems solved!
猜你喜欢
How can a technician take over a complex system?
Test requirements for MIC certification of Bluetooth 2.4G products in Japan
游戏优化性能杂谈(十一) - 知乎
仅用六种字符来完成Hello World,你能做到吗?
More than 50 object detection datasets from different industries
python学习 day1——基础学习
推荐一部经济科普视频,很有价值!
vivoY73s和vivoY70s的区别 vivoY73s和vivoY70s哪个值得入手
模板链表类学习
双向LSTM在时间序列异常值检测的应用
随机推荐
狗狗也能操作无人机!你没看错,不过这其实是架自动驾驶无人机 - 知乎
来自不同行业领域的50多个对象检测数据集
SQL Server 2008R2 18456 error resolution
什么你的电脑太渣?这几招包你搞定! (Win10优化教程)
Recommend an economic science video, very valuable!
面部识别:攻击类型和反欺骗技术
软件测试就是这么回事?!
Python3.9的7个特性
How did Julia become popular?
The most detailed usage guide for perconaxtradbcluster8.0
微信昵称emoji表情,特殊表情导致列表不显示,导出EXCEL报错等问题解决!
nvm
Littlest jupyterhub| 02 using nbgitpuller to distribute shared files
Can you do it with only six characters?
Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
Deeplight Technology Bluetooth protocol SRRC certification services
Game optimization performance (11) - Zhihu
swiper 窗口宽度变化,页面宽度高度变化 导致自动滑动 解决方案
我们采访了阿里云云数据库SQL Server的产品经理,他说了解这四个问题就可以了...
Mouse small hand