关闭

读写文件CFile

标签: filepathoracle数据库bytec
355人阅读 评论(0) 收藏 举报
分类:
void CExportDlg::export()
{
	char record_ver[32];      //导出的记录版本标示
	char c_tem[64];
	char filename[128];
        int i=0, iCount =0;//
	CTime ct=CTime::GetCurrentTime();
	CFile aCFile;
	CString path, strdt=ct.Format("%Y%m%d-%H%M%S");  //-%H%M%S

	//edit by xef 20100426 old code //path=theApp.m_ExportStr+"\\备份导出\\";
	path.Format ("%s%s",theApp.m_ExportStr ,"\\备份导出\\");
	MakeSureDirectoryPathExists(path);
	
	//从注册表中读取最后导出ID
	//CString exportID =ct.Format("%S");

	//创建数据库映像文件exportimage_ver0.dat
	 sprintf(filename,"%sexport%s-%s.dat", path, theApp.m_devID, strdt);
	if(aCFile.Open(filename,CFile::modeCreate|CFile::modeWrite)==0)
	{
		AfxMessageBox("无法创建数据库映像文件");
		return ;
	}
	
	MakeSureDirectoryPathExists(path);
        strcpy(record_ver, "ExportV0");   //备份导出	

	m_progress.SetRange(0, m_sourceCount);
	m_progress.SetPos(0);

	aCFile.Write(record_ver, strlen(record_ver));  //
	aCFile.Write(&i, sizeof(int));                 //是否导入过标志
	aCFile.Write(&m_sourceCount, sizeof(int));       //记录个数

	Write_CString(&aCFile, &theApp.m_devID); //设备id
	
	//开始导出
         char file_names[2048]; //源文件
	char file_named[2048]; //目标文件

	m_pdb_SD->MoveFirst();
	
	while(!m_pdb_SD->IsEOF())
       {
		DoEvents(this->GetSafeHwnd());

		if(m_pdb_SD->m_m_is_up_to_oracle)goto lop1;
	

		//_h.jpg 合成的图片  大图
		if(!GetJDir(m_pdb_SD->m_m_save_dir, m_pdb_SD->m_m_time, file_names, m_pdb_SD->m_m_short_filename2,
		     m_pdb_SD->m_m_operator_code,m_strHaveHour))
		goto lop1;

		SetJDir(path, m_pdb_SD->m_m_time, file_named, m_pdb_SD->m_m_short_filename2, theApp.m_devID);

		CopyFile(file_names, file_named,FALSE);

		//_p.jpg 车牌图片   首先判断若存在,则拷贝
		if(GetJDir(m_pdb_SD->m_m_save_dir, m_pdb_SD->m_m_time, file_names, m_pdb_SD->m_m_short_filename1,
		     m_pdb_SD->m_m_operator_code,m_strHaveHour))
		{

			SetJDir(path, m_pdb_SD->m_m_time, file_named, m_pdb_SD->m_m_short_filename1, theApp.m_devID);
			CopyFile(file_names, file_named,FALSE);
		}

		//
		Write_car_OrderBySD(&aCFile, m_pdb_SD, c_tem);
	
		DoEvents(GetSafeHwnd()); 
		//修改导出标志位
		m_pdb_SD->Edit();
		m_pdb_SD->m_m_is_up_to_oracle =1;
		m_pdb_SD->Update();
		iCount++;         //实际导出的记录个数
lop1:
		m_pdb_SD->MoveNext();

		//更新界面
		m_progress.SetPos(iCount+1);
		sprintf(c_tem,"正在导出:%d 总计 %d", iCount, m_sourceCount);
		SetWindowText(c_tem);
	}
	   
    aCFile.Close();

	CString str;
	str.Format("共计导出了 %d 个记录!", iCount);
	MessageBox(str, "提示");
}

void Write_CString(CFile* pCFile, CString* pCString)
{
	BYTE len=(BYTE)(pCString->GetLength());
	char c_tem[256];
	sprintf(c_tem,"%s", *pCString);
	pCFile->Write(&len, 1);
	pCFile->Write(c_tem, len);
}



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:21884次
    • 积分:439
    • 等级:
    • 排名:千里之外
    • 原创:20篇
    • 转载:6篇
    • 译文:0篇
    • 评论:2条
    文章分类
    最新评论