Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. adding information to a file without overwriting old info

adding information to a file without overwriting old info

Scheduled Pinned Locked Moved C#
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Green Fuze
    wrote on last edited by
    #1

    Hey everybody! lets say I have a file with the following information: string name: "StringName0" and its value is "Text0". now, I want the user to enter more text but it will be saved under a different "StringName", but if I will try to serialize only the new text all I will have in my file is this: "StringName1" and the value "Text1", without "StringName0" and "Text0", it will overwrite the old infomation, what I want to know if there is a way to add the new "StringName" while keeping the old one. maybe I will explain my final goal and than maybe everything will be clearer. I am trying to make a user list for my app, so a new user will enter his "Name", "UserName" and "Password". and there will be a listbox that will contain all Names (so the users can choose themselves). what I am trying to do is that when a new user will add himself, it will ADD the new info into the file without replacing the other users... I am trying to work on this for a long time, and everytime I encounter new problems and I'm really close to give up, so PLEASE HELP ME!!! :(( Thanks in advance!

    R 1 Reply Last reply
    0
    • G Green Fuze

      Hey everybody! lets say I have a file with the following information: string name: "StringName0" and its value is "Text0". now, I want the user to enter more text but it will be saved under a different "StringName", but if I will try to serialize only the new text all I will have in my file is this: "StringName1" and the value "Text1", without "StringName0" and "Text0", it will overwrite the old infomation, what I want to know if there is a way to add the new "StringName" while keeping the old one. maybe I will explain my final goal and than maybe everything will be clearer. I am trying to make a user list for my app, so a new user will enter his "Name", "UserName" and "Password". and there will be a listbox that will contain all Names (so the users can choose themselves). what I am trying to do is that when a new user will add himself, it will ADD the new info into the file without replacing the other users... I am trying to work on this for a long time, and everytime I encounter new problems and I'm really close to give up, so PLEASE HELP ME!!! :(( Thanks in advance!

      R Offline
      R Offline
      rocky_pulley
      wrote on last edited by
      #2

      try to open the file with FileMode: FileMode.Append -- Rocky Dean Pulley

      G 1 Reply Last reply
      0
      • R rocky_pulley

        try to open the file with FileMode: FileMode.Append -- Rocky Dean Pulley

        G Offline
        G Offline
        Green Fuze
        wrote on last edited by
        #3

        my god! it works! :-) Thank You! it really saves again, but I have one more question to understand how exatcly should I load the information. lets say that I'm saving every time using the same "StringName" and only the value changes. and as I saw using the Append it does not overwrite even if it is using the same "StringName", I want to know if there is anyway to load all the values even though all of them has the same StringName of must I create StringName0 and its value, StringName1 and its value, etc. Thanks Alot!!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups