按照日期來存的話需要獲得系統的時間及日期
這裏由於是VC++所以採用了CTime類
舉個例子
CTime Mytime;
Mytime = CTime::GetCurrentTime();
FileNameOmega.Format("D:\\Motor_Rotate\\%s\\",Mytime.Format("%Y-%m-%d-%H-%M-%S"));
// USES_CONVERSION;
// char* Test_Data_Save_Dir_Char;
// Test_Data_Save_Dir_Char = new char[MAX_PATH];
// Test_Data_Save_Dir_Char = T2A(FileNameOmega);
if (!PathIsDirectory(FileNameOmega))
{
//PCSTR str_dir = Test_Data_Save_Dir;
//if(!MakeSureDirectoryPathExists(Test_Data_Save_Dir_Char))
if(!MakeSureDirectoryPathExists(FileNameOmega.GetBuffer()))
{
MessageBox(_T("Failed to create path!"));
}
}
注意幾件事兒
第一文件夾中不能有冒號
第二如果這個程序是多字節字符集的,那麼可以用這段代碼
而如果這個程序是Unicode字符集的,那麼把註釋的內容取消註釋即可,同時要註釋掉當前的這個if
第三,MakeSureDirectoryPathExists這個函數,需要在頭文件中包含
<imagehlp.h>
同時要在項目屬性的連接器中添加一個包含的庫:
imagehlp.lib
方能編譯通過