当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- FORTRAN77从文件中读入若干数据并用heron迭代公式开方
- Solve the problem of rabbitmq message loss and repeated consumption
- Blazor 准备好为企业服务了吗?
- 哔哩哔哩常用api
- vivoS7e和vivoS7的区别 哪个更值得入手
- Wechat nickname Emoji expression, special expression causes the list not to be displayed, export excel error report and other problems solved!
- Shiyou's numerical analysis assignment
- iOS 学习笔记二【cocopods安装使用和安装过程中遇到的问题及解决办法】【20160725更新】
- Spotify是如何推动数据驱动决策的?
- Daily challenges of search engines_ 4_ External heterogeneous resources - Zhihu
猜你喜欢
Python loop distinction (while loop and for loop)
shiyou的数值分析作业
狗狗也能操作无人机!你没看错,不过这其实是架自动驾驶无人机 - 知乎
swiper 窗口宽度变化,页面宽度高度变化 导致自动滑动 解决方案
C++在C的基础上改进了哪些细节
攻防世界之web新手题
What is the difference between vivoy73s and vivoy70s
【计算机网络】学习笔记,第三篇:数据链路层(谢希仁版)
print( 'Hello,NumPy!' )
Deeplight Technology Bluetooth protocol SRRC certification services
随机推荐
高并发,你真的理解透彻了吗?
IQKeyboardManager 源代码看看
IOS upload app store error: this action cannot be completed - 22421 solution
The most detailed usage guide for perconaxtradbcluster8.0
成功解决An error ocurred while starting the kernel
Is blazor ready to serve the enterprise?
Improvement of rate limit for laravel8 update
Solve the problem of rabbitmq message loss and repeated consumption
Adobe Prelude /Pl 2020软件安装包(附安装教程)
SQL Server 2008R2 18456错误解决方案
Six key points of data science interview
M 端软件产品设计思虑札记 - 知乎
Cloud alibabab notes come out, the whole network detailed explanation only this one hand is slow
Fgagt: flow guided adaptive graph tracking
Function periodic table filter value selectedvalue
Windows下子系统Ubuntu安装
What details does C + + improve on the basis of C
计算机网络基本概念(五)局域网基本原理
Astra: Apache Cassandra的未来是云原生
An error occurred while starting the kernel was successfully resolved