المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : how to remove space while writing data to text file using CFile in vc++



C++ Programming
09-10-2009, 04:00 PM
plz help me.This is my code

CFile cTestFile;
cTestFile.Open(_T("D:\\Jitu.txt"),CFile::modeCreate | CFile::modeReadWrite);
CArchive ar(&cTestFile,CArchive::store);

m_pRecordSet = new CDaoRecordset(m_pDatabase);
CString strQuery = _T("SELECT * FROM pdpstate ORDER BY pdpstate.setid");
m_pRecordSet->Open(dbOpenDynaset,strQuery,0);
int nRecordCnt = m_pRecordSet->GetRecordCount();
int nFieldCnt = m_pRecordSet->GetFieldCount();

int ntemp = 8;
COleVariant variantTemp;
for(int nCnt = 0; nCnt < nRecordCnt; nCnt++)
{
for(int nCnt = 0; nCnt < nFieldCnt; nCnt++)
{
variantTemp.Clear();
variantTemp = m_pRecordSet->GetFieldValue(nCnt);
CString csSetID;
csSetID.Format(_T("%d"),variantTemp.intVal);
cTestFile.Write(csSetID,sizeof(csSetID));
cTestFile.Write(_T(","),1);
}
}
cTestFile.Close();


Raj