CFile myFile; int nCount = myFile.Getlength(); myFile.Seek(nCount,CFile::begin);
CFile::Seek virtual LONG Seek( LONG lOff, UINT nFrom ); throw( CFileException );Return ValueIf the requested position is legal, Seek returns the new byte offset from the beginning of the file. Otherwise, the return value is undefined and a CFileException object is thrown.ParameterslOffNumber of bytes to move the pointer.nFromPointer movement mode. Must be one of the following values: CFile::begin Move the file pointer lOff bytes forward from the beginning of the file. CFile::current Move the file pointer lOff bytes from the current position in the file. CFile::end Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to seek into the existing file; positive values will seek past the end of the file. ResRepositions the pointer in a previously opened file. The Seek function permits random access to a file’s contents by moving the pointer a specified amount, absolutely or relatively. No data is actually read during the seek. When a file is opened, the file pointer is positioned at offset 0, the beginning of the file.Example//example for CFile::Seek extern CFile cfile; LONG lOffset = 1000, lActual; lActual = cfile.Seek( lOffset, CFile::begin );
int nCount = myFile.Getlength();
myFile.Seek(nCount,CFile::begin);
virtual LONG Seek( LONG lOff, UINT nFrom );
throw( CFileException );Return ValueIf the requested position is legal, Seek returns the new byte offset from the beginning of the file. Otherwise, the return value is undefined and a CFileException object is thrown.ParameterslOffNumber of bytes to move the pointer.nFromPointer movement mode. Must be one of the following values: CFile::begin Move the file pointer lOff bytes forward from the beginning of the file.
CFile::current Move the file pointer lOff bytes from the current position in the file.
CFile::end Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to seek into the existing file; positive values will seek past the end of the file.
ResRepositions the pointer in a previously opened file. The Seek function permits random access to a file’s contents by moving the pointer a specified amount, absolutely or relatively. No data is actually read during the seek. When a file is opened, the file pointer is positioned at offset 0, the beginning of the file.Example//example for CFile::Seek
extern CFile cfile;
LONG lOffset = 1000, lActual;
lActual = cfile.Seek( lOffset, CFile::begin );
如果用CFile类,打开后调用
file.Seek(0,CFile::end);
如果是CreateFile,要用
SetFilePointer()了
int nCount = fl_ErrLog.GetLength();
fl_ErrLog.Seek(nCount, CFile::begin);CArchive ar_ErrLog(&fl_ErrLog, CArchive::store);
m_ErrLog.Serialize(ar_ErrLog);
ar_ErrLog.Close();fl_ErrLog.Write("\n",1);
fl_ErrLog.Close();
写完一行后.myFile.write("\n",1)
可是在我的程序中不好用啊,写进的数据还是没有换行.