天天看點

【測寬儀項目】彈出file.txt Line308的BUG解決方案

師兄改的代碼,具體出現的問題是createdirectory這個函數。

UINT CGigeCameraDemoDlg::Measure(void *param)
{
	CString Value;
	while (1)
	{
		if (success) 
		{
			Sleep(500);
			CTime time_now_;
			time_now_ = CTime::GetCurrentTime();
			time_str = time_now_.Format("%Y_%m_%d");
			//std::wcout << time_str.GetBuffer() << " ";
			if (!PathIsDirectory(LPCWSTR(value_Path + "\\" + time_str+"\\"+coil_number)))
			{
				CreateDirectory(LPCWSTR(value_Path + "\\" + time_str), 0);
				CreateDirectory(LPCWSTR(value_Path + "\\" + time_str+"\\"+coil_number), 0);
			}
			else {
				
				CTime time_now__;
				time_now__ = CTime::GetCurrentTime();
				CString time_ = time_now__.Format("%H:%M:%S");
				CStdioFile myFile;
				CFileException fileException;
				if (myFile.Open(LPCWSTR(value_Path + "\\" + time_str+ "\\" + coil_number +"\\"+"measure.txt"), CFile::typeText | CFile::modeCreate | CFile::modeReadWrite | CFile::modeNoTruncate), &fileException)
				{
					
					char buf[32] = { 0 };
					sprintf(buf, "%S%s%f", time_, " ", Width);
					myFile.SeekToEnd();
					myFile.Write(buf, 32);
					myFile.WriteString(_T("\n"));
					myFile.Close();

				}
			}
		}
		}
		
	return 0;
}