Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.0 C#3.0
i m working on windows application and i want to save textbox date in a file when i button clicked and file extension is .html .
 

 
Thanks in Adv..
 
Regard
Sham
Posted 28-Sep-12 1:37am
Comments
shambhoo kumar at 28-Sep-12 7:02am
   
Any one help me..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

using System;
using System.IO;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
    public Form1()
    {
        InitializeComponent();
    }
 
    private void button1_Click(object sender, EventArgs e)
    {
        //
        // This is the button labeled "Save" in the program.
        //
        File.WriteAllText("C:\\demo.html", textBox1.Text);
    }
    }
}
or Use this in button click event..
//Use StreamWriter class.
StreamWriter sw = new StreamWriter("E:\\test.html");
 
//Use write method to write the text
sw.Write(textBox1.Text);
 
//always close your stream
sw.Close();
Also can see it..
http://www.dotnetspider.com/resources/31161-Creating-html-file-with-text-box-data.aspx[^]
  Permalink  
v3
Comments
shambhoo kumar at 28-Sep-12 7:22am
   
Thank frnd...
 
Regard
Sham
:)
ridoy at 28-Sep-12 7:33am
   
welcome.happy coding..:)

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



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100