VideoHelp.com Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Man of Steel freebird73717's Avatar
    Join Date: Dec 2003
    Location: Smallville, USA
    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

    Code:
    void Button3Click(object sender, EventArgs e)
    		{
    			if (saveFileDialog2.ShowDialog() == DialogResult.OK);
    		}
    Any help would be appreciated.
    Donadagohvi (Cherokee for "Until we meet again")
    My Video Tools :: Free Security Software :: Ubuntu Antivirus Rescue CD
    Quote Quote  

  2. Member tekkieman's Avatar
    Join Date: Mar 2004
    Location: Over the hill
    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);
    The streamwriter constructor take a path to your file, and the true/false parameter is for appending/overwriting. In my code, the logfile is a FileInfo object, and the fullname property contains the fully qualified path/filename. The writeline sends the line of text to the file. Remember to close the file when finished writing.


    Hope this helps. Let me know if you need more...
    Quote Quote  

  3. Man of Steel freebird73717's Avatar
    Join Date: Dec 2003
    Location: Smallville, USA
    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();
    		};}
    I do appreciate the help though.

    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")
    My Video Tools :: Free Security Software :: Ubuntu Antivirus Rescue CD
    Quote Quote  




Similar Threads

  1. Replies: 1
    Last Post: 25th Feb 2010, 08:54
  2. Replies: 4
    Last Post: 8th Jun 2009, 13:11
  3. Replies: 2
    Last Post: 17th Apr 2009, 13:56
  4. Replies: 6
    Last Post: 27th Jun 2008, 10:38
  5. Adding text over original text
    By stixster in forum Editing
    Replies: 3
    Last Post: 17th Jun 2008, 05:14
Search   Contact us   About   Advertise   Forum   RSS Feeds   Statistics   Tools