3
Answers

how to use streamwriter/streamreader?

Photo of meng

meng

12y
5.3k
1

i'm try to use streamwriter to save the data from a listbox (in C#) to a text file, but my code is saving the ojectcollection instead of the data from the listbox.

a) data saved to text file is "System.Windows.Forms.ListBox+ObjectCollection"

b)
FileStream dFile = new FileStream("C:\\temp\\data.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(dFile)
//write data to file
sw.WriteLine("{0}", listBox1.Items);
sw.Close();

 

C) please advise how to load data from the saved text file to a lisbox?



 

thanks

Answers (3)

0
Photo of Manpreet Singh
NA 51.4k 2.4m 10y
Hi Shiny,


Can you tell me which broser are you using?


Cheers !
Manpreet
0
Photo of Shiny Joseph
NA 6 1.4k 10y
Thanks Vithal for the response.
Have tried this but no luck.
Appreciate your help further.

Regards,
Shiny Joseph
0
Photo of Vithal Wadje
NA 47.6k 23.3m 10y
I think its due to windows authentication ,try by opening studio as Run as administrator