Using Text Files
-
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?
Yes - Its possible :)
Coding C# ExciteTemplate
-
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?
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
-
Yes - Its possible :)
Coding C# ExciteTemplate
-
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
-
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
-
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
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:
-
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:
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