Read
Read data into a buffer from the file associated with the file object.
UINT Read( void * lpBuf, UINT nCount )
Number of bytes read from the file. May be less than nCount if EOF is reached.
EX1
int file_Read_ex1() { file ff; bool bOK = ff.Open("c:\\test.txt", file::modeCreate | file::modeNoTruncate | file::modeRead); if(!bOK) { out_str("Failed to open file C:\test.txt"); return 0; } int aa, intlist[4]; ff.Read(&aa, sizeof(aa)); ff.Read(intlist, sizeof(intlist)); //ff.Read(&intlist[0], sizeof(intlist)); //read double double bb; ff.Read(&bb, sizeof(bb)); //read structure WIN32_FIND_DATAA cc; ff.Read(&cc, sizeof(cc)); //read char array char dd[20]; ff.Read(dd, sizeof(dd)); //read vector vector<int> kk; kk.SetSize(5); int size = sizeof(int) * kk.GetSize(); ff.Read(kk, size); return 1; }
EX2
//read data to the 1st column of active worksheet with dataset //assume all datas are numeric int file_Read_ex2() { file ff; bool bOK = ff.Open("C:\\test.txt", file::modeCreate | file::modeNoTruncate | file::modeReadWrite); if(!bOK) { out_str("Failed to open file C:\test.txt"); return 0; } Worksheet wks = Project.ActiveLayer(); Column cc; if(wks) cc = wks.Columns(0); else out_str("Iinvalid worksheet"); //get data cc.SetInternalData(FSI_DOUBLE); Dataset ds(cc); int nDataSize = 5; ds.SetSize(nDataSize); //write data int nRead = ff.Read(ds, nDataSize * sizeof(double)); return 1; }
File::Write
origin.h