CDataFile Class

Environment: VC++ 6.0. SP5, Win2k SP2

Functions and Usage

The main functions of CDataFile are shown in the following:

1. Create a file with two modes:

Function : BOOL CDataFile::CreateFile(LPCTSTR lpszFileName, UINT nFlags)

Usage: nFlags may be CREATE_MODE_REBUILD (Whether the file exists or not, recreate it) or CREATE_MODE_NOREBUILD (If the file has existed ,do not recreate it)

2. Open a file with three modes:

Function : BOOL CDataFile::OpenFile(LPCTSTR lpszFileName, UINT nFlags)

Usage: nFlags may be OPEN_MODE_READ ,OPEN_MODE_WRITE ,OPEN_MODE_READWRITE

3. Check a file whether it has exisited:

Function : INT CDataFile::CheckFileExsist(LPCTSTR lpszFileName)

Usage : Return values may be FLAG_FILE_EXIST , FLAG_FILE_NOEXIST

4. Get the number of lines in the file:

Function : UINT CDataFile::GetLines()

Usage : Return value is the number of lines.

5. Move the pointer to the line you want to operate:

Function : BOOL CDataFile::MoveToLine(UINT line)

Usage : If you want to use ReadLine() or WriteLine(),you must use MoveToLine() first.

6. Read the line you move to:

Function: BOOL CDataFile::ReadLine(CString &rString)

7. Insert, overwrite, delete a line at current line:

Function : void CDataFile::WriteLine(CString &wString, UINT nFlag)

Usage : nFlag may be WRITE_MODE_INSERT ,WRITE_MODE_OVERWRITE or WRITE_MODE_DELETE.If nFlag is WRITE_MODE_DELETE , the wString is the content of the line you will delete.

8. Close a file:

Function : void CDataFile::CloseFile()

Downloads

Download demo project - 24 Kb
Download source - 3 Kb


Comments

  • nice & lite code~

    Posted by Legacy on 08/12/2002 12:00am

    Originally posted by: neoleftz

    nice & lite code~

    Reply
  • Works fine

    Posted by Legacy on 07/31/2002 12:00am

    Originally posted by: Matthias

    ..It does what It should do (As far as I used it). Thanks for this Class

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Corporate e-Learning technology has a long and diverse pedigree. As far back as the 1980s, companies were adopting computer-based training to supplement traditional classroom activities. More recently, rich web-based applications have added streaming audio and video, real-time collaboration and other new tools to the e-Learning mix. At the same time, the growing availability of informal learning tools--a category that includes everything from web searches to social media posts--are having a major impact on …

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds