Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read and write to .txt file?

Status
Not open for further replies.

fdpelli

Technical User
Sep 12, 2003
5
0
0
SE
Hello

I'm never programmed with VB.NET (and no other VB lang, just C++) and wonder how to read from a .txt file, say the first line of the file, and I also wonder how to write to it.

Thank you.

/ Per aspera ad astra
 
Access the file with a filestream and use the streamreader and streamwriter classes to read/write to it.

For example
dim fs as new filestream("C:\myfile.txt",filemode.open)
dim sr as new streamreader(fs)
dim firstline as string
firstline=sr.readline
 
Thanks kmcdonag!

But there is still one thing that I (and other Scandinavians plus Germans) got a problem with. It doesen't copy our special characters. (You know, the a with two dots over it, and the o with two dots and so on.)

How do I read them correct?

/ Per aspera ad astra
 
Ók fdpelli

well i hope that you have found your answer until now, but if you havent. Her is something that meget help you. I to wanted to make an editor which could take my native language. So first of all you have to make shore that you have installed the language pak from (in your own language) in your windows. and the rest seems to be easy in VB .net anyway. Under the propertyes of your textbox or what ever editro (texteditor) you have chosen. and under the font choice your native language and you then you are op and going.
 
Oh, so it wasn't more difficult than that...

Thank you, I'll check the properties better next time, so I don't waste your time...

/ Per aspera ad astra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top