Computing.Net > Forums > Programming > Save Listbox data to txt file?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Save Listbox data to txt file?

Reply to Message Icon

Name: pds2ect
Date: September 16, 2007 at 11:32:04 Pacific
OS: Windows XP
CPU/Ram: 1.60 GHz, 512 MB RAM
Comment:

I am using Visual Studio 2005 and am trying to save the data gathered in a listbox to a .txt file on my HD. Any samples of code you can provide will be greatly appreciated.
Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: Bexm
Date: September 17, 2007 at 05:14:18 Pacific
Reply:

Something like this.... ( I am assuming our creating a web app.., but if not it will still be similar)

static void WriteToFile()
{
StreamWriter SW;
SW=File.Create("c:\\MyTextFile.txt");

foreach(ListItem item in ListBox.items){
SW.WriteLine(item.text);

}

SW.Close();
}


0

Response Number 2
Name: pds2ect
Date: September 17, 2007 at 10:16:29 Pacific
Reply:

I am developing an application for windows. I want the user to be able to save the items in the listbox to a file of their choice on their hard drive as a text file. I am fairly new to VB but have managed to get everything working except the saving of the data. I need to let the user choose the filename as they may require more than one lot of items to be saved from the listbox.
Thanks for your help so far.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Batch image to folder/ima... Map all printers on a pri...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Save Listbox data to txt file?

Perl : converting .elf (binary) to .txt file www.computing.net/answers/programming/perl-converting-elf-binary-to-txt-file/20052.html

Perl : converting .elf (binary) to .txt file www.computing.net/answers/programming/perl-converting-elf-binary-to-txt-file/20055.html

Appending txt files in VB www.computing.net/answers/programming/appending-txt-files-in-vb/9577.html