CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: CFile

  1. #1
    Join Date
    May 1999
    Posts
    30

    CFile

    Hi every one, i wish you are doing good. I would like to know if it is possible to do an append with the class CFile to put more record in 1 file after you restart the application.


  2. #2
    Join Date
    Apr 1999
    Posts
    25

    Re: CFile

    Hello,

    I don't recall that CFile class has an append mode, but I think you can open one with CFile::modeWrite | CFile::modeNoTruncate mode so that the file won't be destroyed if it exists. Then you can seek the end of file with SeekToEnd() method and write new stuff in the file.


  3. #3
    Join Date
    May 1999
    Posts
    30

    Re: CFile

    Thank you really much. Now, how do i open the file. It is giving me an error message when i am trying to open it.


  4. #4
    Join Date
    Apr 1999
    Posts
    25

    Re: CFile

    Hello again,

    If the error occurs when you are trying to reopen the file, it may be because you have not closed it after you first opened it. Otherwise, check what the error is. The Open method of CFile class lets you provide a pointer as the third argument to find out what the error is, or you can use a try/catch block:

    try{ YourFile.Open(.....) }
    catch(CFileException fileError)
    {
    AfxMessageBox("Something wrong!");
    ...
    }




    Exactly what was wrong can be found in the data members of the CFileException object thrown by the Open method.



  5. #5
    Join Date
    May 1999
    Posts
    30

    Re: CFile

    thank you. that is good to have people like you (specialist).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured