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. Using Text Files

Using Text Files

Scheduled Pinned Locked Moved C#
data-structuresquestion
8 Posts 4 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
    gamer1127
    wrote on last edited by
    #1

    Hello. I just want to know if its possible for me to store the data inside an array to a text file and also if its possible to transfer all the data in the text file into an array?

    C OriginalGriffO 2 Replies Last reply
    0
    • G gamer1127

      Hello. I just want to know if its possible for me to store the data inside an array to a text file and also if its possible to transfer all the data in the text file into an array?

      C Offline
      C Offline
      Coding C
      wrote on last edited by
      #2

      Yes - Its possible :)

      Coding C# ExciteTemplate

      G 1 Reply Last reply
      0
      • G gamer1127

        Hello. I just want to know if its possible for me to store the data inside an array to a text file and also if its possible to transfer all the data in the text file into an array?

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        As Coding says, yes it is possible. How you do it will depend on what kind of info you have in your array, and what you want to do with the text file. If it is an array of strings, easy peasy. If it is an array of something else, then slightly harder - you will either have to do the work yourself or use a Formatter - XML, Binary or Soap.

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        G 1 Reply Last reply
        0
        • C Coding C

          Yes - Its possible :)

          Coding C# ExciteTemplate

          G Offline
          G Offline
          gamer1127
          wrote on last edited by
          #4

          Ok..Thanks.. ;)

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            As Coding says, yes it is possible. How you do it will depend on what kind of info you have in your array, and what you want to do with the text file. If it is an array of strings, easy peasy. If it is an array of something else, then slightly harder - you will either have to do the work yourself or use a Formatter - XML, Binary or Soap.

            No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

            G Offline
            G Offline
            gamer1127
            wrote on last edited by
            #5

            oh..ok then..thanks for the info..

            OriginalGriffO 1 Reply Last reply
            0
            • G gamer1127

              oh..ok then..thanks for the info..

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Sorry, that was a little unhelpfull! For an array of strings, look at File.WriteAllLines[^]. To read it back, use ReadAllLines For an array of something else, you will need to: 1) Open file 2) Set up a loop through each element of the array 3) For each element, use ToString member, or string.Format to create a string 4) Write the string to the file 5) Close the file. To read them back, use the Parse method after reading the line. or look at BinaryFormatter, XMLFormatter and SoapFormatter in the MSDN, but these will not necessarily create a file you want to look at, or edit by hand! Good luck!

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              L 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Sorry, that was a little unhelpfull! For an array of strings, look at File.WriteAllLines[^]. To read it back, use ReadAllLines For an array of something else, you will need to: 1) Open file 2) Set up a loop through each element of the array 3) For each element, use ToString member, or string.Format to create a string 4) Write the string to the file 5) Close the file. To read them back, use the Parse method after reading the line. or look at BinaryFormatter, XMLFormatter and SoapFormatter in the MSDN, but these will not necessarily create a file you want to look at, or edit by hand! Good luck!

                No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                TMI the first "yes" was the best answer :laugh:

                Luc Pattyn

                :badger: :jig: :badger:

                Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

                :jig: :badger: :jig:

                OriginalGriffO 1 Reply Last reply
                0
                • L Luc Pattyn

                  TMI the first "yes" was the best answer :laugh:

                  Luc Pattyn

                  :badger: :jig: :badger:

                  Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

                  :jig: :badger: :jig:

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  I thought so - it was an accurate and complete answer - but not so helpful to a beginner! :laugh: :laugh: That's why I apologised and gave more info. I'm trying to obey the new rules...but some of these questions do make it difficult.

                  No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  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