这属于visual studio 2013(v120)。如何在visual studio 2010(v100)中进行转换?
{
...
DateTime now = DateTime.Now;
DateTime firstExecute = new DateTime( now.Year, now.Month, 15 ); //add time if needed...
if ( firstExecute < now )
{
firstExecute.AddMonth( 1 );
}
timer.Interval = (firstExecute - now).TotalMilliseconds;
}
两个错误: 首先:h = FindFirstFile(b,&amp; fb); 13智能感知:标识符&#34; fb&#34;未定义c:\ users \ administrator \ documents \ visual studio 2010 \ projects \ file cleaner \ file cleaner \ search.h 90 25文件清理器
第二:WIN32_FIND_DATA fa {0},fb {0}; 12智能感知:预期a&#39 ;;&#39; c:\ users \ administrator \ documents \ visual studio 2010 \ projects \ file cleaner \ file cleaner \ search.h 85 21文件清理器
答案 0 :(得分:0)
您无法排序CStringArray
(至少不容易),您必须将其转换为vector<wstring>
或vector<string>
等。
使用此功能将CStringArray
转换为vector<wstring>
:
CStringArray sa;
vector<wstring> vws;
vws.resize(0); //CStringArray to vector<string>
for (int i = 0; i < sa.GetCount(); i++)
vws.push_back((const wchar_t*)sa[i]);
sa.RemoveAll(); //vector<string> back to CStringArray
for (int i = 0; i < (int)vws.size(); i++)
sa.Add(vws[i].c_str());
CString
在MFC中占有一席之地,但CStringArray
并不重要,您可以取消它并使用vector<CString>
代替:
vector<CString> vcs;
//fill vcs...
struct {
bool operator()(const CString &a, const CString &b)
{
WIN32_FIND_DATA fa{ 0 }, fb{ 0 };
HANDLE h;
h = FindFirstFile(a, &fa);
if (h != INVALID_HANDLE_VALUE) FindClose(h);
h = FindFirstFile(b, &fb);
if (h != INVALID_HANDLE_VALUE) FindClose(h);
return 1 == CompareFileTime(&fa.ftCreationTime, &fb.ftCreationTime);
}
} sortproc;
sort(vcs.begin(), vcs.end(), sortproc);