采用以下代码实现
hFile = CreateFile( _T("\\Storage Card\\Log.txt"), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL );
if ( hFile != INVALID_HANDLE_VALUE )
{
dwToWrite = len ;//strlen( chBuffer );
SetFilePointer( hFile, 0, NULL, FILE_END );
SetEndOfFile( hFile );
WriteFile( hFile, chBuffer, dwToWrite, &dwWritten, NULL );
CloseHandle( hFile );
}
也可采用以下方式进行
FILE * filesave;
if( (filesave = _wfopen(SAVEFILE, _T("a+") )) == NULL )
{
MessageBox(_T("保存文件打开失败!"),_T("盈趣科技"),MB_OK);
return 1;
}
while(!feof(filesave))
{
fgets(savebuff, sizeof(savebuff), filesave);
if(strcmp(savebuff,filesavebuf)==0)
{
FileSameFlg = TRUE;
}