How do I open a new/current file

webster972

Member
Joined
Jun 23, 2004
Messages
7
Hi, Im pretty new to VB.NET, I have a school assignment and I was wondering how could I pop up a list box to create a new file or open an existing file, for example I want my "load" button to open listbox to search for a file in the current directory, like MS-office for example. thanks!
 
Iceplug said:
So, you want files that are in the directory to show up in the listbox? Why not use the Open File Dialog component? :)[/QUOTE



Hmm...I want the filenames listed in a textbox....for example..if I opened 1.txt, 1.txt will show i the textbox....then if I closed 1.txt and opened 2.txt......the textbox shoould now have 1.txt and 2.txt......is this possible?
 
So, whats the point of closing 1.txt if its text remains in the TextBox... unless you are talking about closing the StreamReader.

You are trying to store the filenames right? (Not the contents of the file)
It would seem to be better to have them in a textbox.

So, how is the user selecting a file? The open file dialog? If so, then you can just add the open file dialogs Filename.

ListBox.Items.Add(OFD.Filename)
TextBox.AppendText(OFD.Filename)
:)
 
Iceplug said:
So, whats the point of closing 1.txt if its text remains in the TextBox... unless you are talking about closing the StreamReader.

You are trying to store the filenames right? (Not the contents of the file)
It would seem to be better to have them in a textbox.

So, how is the user selecting a file? The open file dialog? If so, then you can just add the open file dialogs Filename.

ListBox.Items.Add(OFD.Filename)
TextBox.AppendText(OFD.Filename)
:)


Basically, I just want to load all the file names that I open through the open file dialog and list them in the textbox, the user does this by clicking on a load button I have made. Im new to VB.net, and this is for a school assignment, so if my responses seem redundant or far off, please excuse me, thanks! ima try your code right now..
 
webster972 said:
Basically, I just want to load all the file names that I open through the open file dialog and list them in the textbox, the user does this by clicking on a load button I have made. Im new to VB.net, and this is for a school assignment, so if my responses seem redundant or far off, please excuse me, thanks! ima try your code right now..

thanks, I just tried out your code and it worked perfectly, now I just have to make the listbox scrollable.
 
Back
Top