|
-
Feb 21st, 2003, 08:40 PM
#1
Thread Starter
Frenzied Member
Open file !?
I'm trying out VB.Net, which is actually very cool!
I've been playing a bit around with it, but i'm not quite sure on how to open a file and load it into a string.
I just OpenFileDialog.OpenFile to load the file... And i THINK it is loaded, i just don't know how to get it into the textbox, please help :-)!
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Feb 21st, 2003, 08:54 PM
#2
The openfile dialog only gets the path it doesn't load the file for you. Try something like this:
VB Code:
'this loads all the contents of the test.txt file in the application folder
'opens the file as a stream
Dim fs As New IO.FileStream("test.txt", IO.FileMode.Open)
'adds a reader to read from the stream
Dim sr As New IO.StreamReader(fs)
'reads all the data in the stream/file into the string variable
Dim contents As String = sr.ReadToEnd
'close the file very important
fs.Close()
'this is just to show you that the data is loaded
MsgBox(contents.ToString)
Last edited by Edneeis; Feb 22nd, 2003 at 03:54 PM.
-
Feb 22nd, 2003, 06:43 AM
#3
Thread Starter
Frenzied Member
Thanks!!
wow, makes sence with the comments 
Thanks!!
Cheers !
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|