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

    How to read/write CString from/in CFile ?

    please help me, how can I read and write CStrings from/into CFiles ?
    I tried e.g
    pChar=LPCTSTR(sString);
    pFile->Write(pChar, sString.GetLength()+1);
    or
    pFile->Write(sString, sString.GetLength());

    and

    pFile->Read(sString.GetBuffer(512), 512);
    sString.ReleaseBuffer();

    what is wrong ?
    How can i write and retrieve that damned CStrings ?

    Greetin'
    Jay


  2. #2
    Join Date
    May 1999
    Posts
    53

    Re: How to read/write CString from/in CFile ?

    Try using a CArchive, then

    CArchive ar;
    CString str;
    ar << string;


    to read:
    ar >> string;



  3. #3
    Join Date
    May 1999
    Posts
    36

    Re: How to read/write CString from/in CFile ?

    Hi,

    Look at CStdioFile instead of CFile. It's designed to handle strings.

    HTH,

    Harvey Hawes

    Software Engineer
    BioScience Analysis Software Ltd.

    Masters Candidate
    Cardiovascular/Respiratory Sciences
    Faculty of Medicine
    University of Calgary
    Calgary, Alberta, Canada

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