Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an application which is in f drive.while running that application i store all the values in a listbox.I wanted to view the values in a txt file after closing the application so i used stream writer and text writer...the file is created in f drive where the actual project resides...in debug folder...but..thing is i want to save on desk top..so i am giving the piece of code here...plz chk ..

using (FileStream fs3 = File.Create("values.txt"))
{
using (TextWriter tw = new StreamWriter(fs3))
{
int p;
string value;
for (p = 0; p < listBox2.Items.Count; p++)
{
value=listBox2.Items[p].ToString();

tw.Write(value);
tw.Write(\r\n);

}


}
}
Posted

1 solution

 
Share this answer
 
Comments
Shmuel Zang 7-Mar-13 1:24am    
5'ed. I was about to give the same link.
Mehdi Gholam 7-Mar-13 1:27am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900