Re: Write and Read txt Files
lol exact same thing i'm looking for.
can't sort it out yet. wish it was as easy as in php.
Re: Write and Read txt Files
Have either of you considered searching this forum or just doing a general google search?
There are literally hundreds of people have already asked the question on here and been given examples and help, and a google search using the keywords "reading and writing text files vb.net" returned 1.2 million pages.
Re: Write and Read txt Files
It's like this
Dim line As New List(Of String)
line.AddRange(IO.File.OpenText("C:\hi.txt").ReadToEnd.Split(Environment.NewLine))
Re: Write and Read txt Files
Thx Choller, that one worked out.
@Paul
Yes, I've searched through Google and even YouTube. But all I find is to make one single file with one Line on it. Considering to search on this forum, I did found a lot of examples, but those examples does not fit to my use.
Re: Write and Read txt Files
Quote:
Yes, I've searched through Google and even YouTube. But all I find is to make one single file with one Line on it.
OK I went back to my google search using the keywords I described above, and looked at the first two results. Both showed explicitly how to create a text file and in both occasions showed examples of writing multiple lines of data. Even if they hadn't and you have an example showing you how to write one line of data it isn't exactly a huge leap to work out how to write two lines.
I'm not going to go through the other 1,209,998 pages returned in the results but I'm prepared to bet that most of them (if not all) would tell you exactly what you need to do.
Re: Write and Read txt Files
To be honest I googled to and I couldn't find a really simple solution. Everything was wrapped around some piece of extra code and it wasn't easy to figure it out.
After coming back to this forum and using the search functions here I was able to find it.
Re: Write and Read txt Files
vb Code:
dim read as system.io.streamreader = my.computer.filesystem.opentextfilereader("C:/myfile.txt")
dim text = read.readtoend()