CStdioFile problem

Discussion in 'MFC' started by meyup, May 30, 2010.

  1. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    I have a problem!
    :confused:
    after reading strings from a file (with ReadString want), I overwrite certain strings with new ones.
    WriteString The write command is ignored. Who can help?
     
  2. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    do you have to file as CFile:: modeRead only open maybe??

    need to write CFile:: Write mode | CFile:: modeCreate if it does not exist!

    Code:
    CStdioFile f; 
    CString m_LogFileName = " File.log "; 
    
        if (f.Open (m_LogFileName, CFile:: Write mode) == FALSE) 
    ( 
            if (f.Open (m_LogFileName, CFile:: modeCreate | CFile:: Write mode) == TRUE) 
    ( 
    f.WriteString (cstrZeit + "" + cstrZeile + ' \ n ') 
    f.close (); 
    ) 
    ) 
        else 
    ( 
    f.SeekToEnd (); 
            / / f.WriteString ("####### ############################## \ n "); 
    f.WriteString (cstrZeit + "" + cstrZeile + ' \ n ' ) 
    f.close (); 
    )
     
  3. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    No, it did with "Mitarbeiter_File.Open (file_name, CFile:: modeReadWrite) opens.
    Detailed problem description: This is a password check.
    4 * If the employee has entered the wrong password, the file will be overwritten the saved password in by a "special password,
    a log again in general (the correct password) to stop using it.
     
  4. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    Then you must close it and open it with write mode and enter your new car as I have it above hingepostet.

    Because the file exists, can you query with the CFile:: Write mode | CFile:: modeCreate also pay.
     
  5. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    How can I then overwrite the old password? That is, how do I get to the point where the old password is?
    Your method makes it but I believe only one adding the new password at end of file, right? :confused:
     
  6. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    you have to read through the text until you have found the old password. then you realize you the places and replaces the old password just by the new!
     
  7. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    How can you remember the place (will surely be sought in read-mode right?)? How can we get there in write mode?
    Why is there a mode modeReadWrite "if you only close the file and write mode has to re-open with?
     
  8. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    I mean that you do with CFile:: GetPosition ()

    is detailed in the MSDN I mean
     
  9. creative

    creative New Member

    Joined:
    Feb 15, 2010
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    If you a certain position in the file write off will overwrite the existing and not supplements!
    That is only if your new password length is just like your old or length for you to store the password you provided a solid, everything is ok.
    :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice