How do i open any existing file in VC++ without losing its contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harishmitty
    New Member
    • Sep 2008
    • 1

    How do i open any existing file in VC++ without losing its contents

    Lemme explain exactly what am doing. Its pretty simple.

    String^ file_name = "c:\\test.t xt";
    StreamWriter^ sw = gcnew StreamWriter(fi le_name);
    sw->WriteLine("Hel lo");

    When I do this, everytime I run this program, the existing file is opened by erasing its contents. How can I avoid this, so that I can append this new text to EOF (End Of File) everytime?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Use the StreamWriter Constructor (String, Boolean)rather than the StreamWriter Constructor (String).

    Look up the StreamWriter class on MSDN, Google is your friend.

    Comment

    Working...