从文件中读取数据
CFile fileEditText; //Declare and open a file for reading
CString strsend;
if(fileEditText.Open("c:\\1.txt",CFile::modeRead))
{
char cBuf[512]; //Declare a large buffer for reading the text
UINT uBytestRead;
//Continue reading until no more data is read
while(uBytestRead=fileEditText.Read(cBuf,sizeof(cBuf)-1))
{
cBuf[uBytestRead]=NULL; //NULL terminate after the last character
strsend+=CString(cBuf); //Add the buffer to the mapped CString
}
fileEditText.Close();//Close the file
CString strsend;
if(fileEditText.Open("c:\\1.txt",CFile::modeRead))
{
char cBuf[512]; //Declare a large buffer for reading the text
UINT uBytestRead;
//Continue reading until no more data is read
while(uBytestRead=fileEditText.Read(cBuf,sizeof(cBuf)-1))
{
cBuf[uBytestRead]=NULL; //NULL terminate after the last character
strsend+=CString(cBuf); //Add the buffer to the mapped CString
}
fileEditText.Close();//Close the file
浙公网安备 33010602011771号