Hello.
I am in the process of writing a gui and am stuck on one piece of code. I have a listbox that contains text. I would like to click my save button and be able to save the contents of the listbox to a text file. So far I can click "save" and give the file I'm "saving" a name and that goes okay...but nothing really happens. I know I need to use a function like streamreader and or streamwriter I'm just at a loss how. Any body have any clues?
Here is the code I have now
Any help would be appreciated.Code:void Button3Click(object sender, EventArgs e) { if (saveFileDialog2.ShowDialog() == DialogResult.OK); }
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 3 of 3
Thread
-
Donadagohvi (Cherokee for "Until we meet again")
-
Here's some code from an app that writes to a file:
Code:StreamWriter log = new StreamWriter(logfile.FullName, true); log.WriteLine(DateTime.Now + "\t Could not find the ini file - " + aName + Environment.NewLine);
Hope this helps. Let me know if you need more... -
Thanks for the reply tekkieman. I tried your code but got errors. However I did come up with some code that works.
Code:void Button3Click(object sender, EventArgs e) { if (saveFileDialog2.ShowDialog() == DialogResult.OK) { System.IO.StreamWriter sw = new System.IO.StreamWriter(saveFileDialog2.FileName); foreach (object item in listBox1.Items) sw.WriteLine(item.ToString()); sw.Close(); };}
My gui is finished now. It is a batch processing gui for HCenc. I started a new thread on it Here. If you get the chance you might check it out and give me some feedback. It is my first attempt at writing a gui.Donadagohvi (Cherokee for "Until we meet again")
Similar Threads
-
Read text create audio and convert text to synced subtitles in mp4
By Philip Lean in forum SubtitleReplies: 1Last Post: 25th Feb 2010, 08:54 -
Adding 'syntex' highlighting or 'color text' to source code snips ?
By vhelp in forum FeedbackReplies: 4Last Post: 8th Jun 2009, 13:11 -
How to save avi embedded subtitles into a text file?
By markiz in forum SubtitleReplies: 2Last Post: 17th Apr 2009, 13:56 -
looking for good OCR software that will convert text in jpg to regular text
By jimdagys in forum ComputerReplies: 6Last Post: 27th Jun 2008, 10:38 -
Adding text over original text
By stixster in forum EditingReplies: 3Last Post: 17th Jun 2008, 05:14