Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Comments
Shambhoo kumar 28-Sep-12 7:02am    
Any one help me..

1 solution

C#
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[^]
 
Share this answer
 
v3
Comments
Shambhoo kumar 28-Sep-12 7:22am    
Thank frnd...

Regard
Sham
:)
ridoy 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)



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