同意 snaill(com.chinaos.snaill) ( ) 部分观点。但反对用 char[]建议使用 new char [文件长]来搞
CFile::typeBinary 你可以用BYTE[]来存储,用CString不妥当。
CFile id_file; if (!id_file.Open("c:\\hpzp\\hpjldver.con",CFile::modeRead|CFile::typeBinary)) { AfxMessageBox("打开文件失败!"); return ; } BYTE buffer[4096]; DWORD dwRead; // Read in 4096-byte blocks, // remember how many bytes were actually read, // and try to write that many out. This loop ends // when there are no more bytes to read. do { dwRead = id_file.Read(buffer, 4096); } while (dwRead > 0); // Close both files id_file.Close();
CFile::Read
CString::GetBuffer
CString::ReleaseBuffer
干嘛用的?
而是用+ = 等操作可能会变化其中的数据
定义一个大的char[]数组。
同意 snaill(com.chinaos.snaill) ( )
部分观点。但反对用 char[]建议使用 new char [文件长]来搞
你可以用BYTE[]来存储,用CString不妥当。
if (!id_file.Open("c:\\hpzp\\hpjldver.con",CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox("打开文件失败!");
return ;
}
BYTE buffer[4096];
DWORD dwRead; // Read in 4096-byte blocks,
// remember how many bytes were actually read,
// and try to write that many out. This loop ends
// when there are no more bytes to read. do
{
dwRead = id_file.Read(buffer, 4096);
}
while (dwRead > 0); // Close both files id_file.Close();