you can try to use code below to write the data from textbox to text file.
protected void Button1_Click(object sender, EventArgs e)
{
string currtm = DateTime.Now.ToString();
string lines = "Code sent in Textbox: Time-" + currtm + Environment.NewLine + TextBox1.Text;
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\v-padee\Desktop\demo.txt",true);
file.WriteLine(lines);
file.Close();
}
it will give you output like below.
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
200 Points
692 Posts
saving all data in textfile
Sep 05, 2016 08:42 AM|Lexi85|LINK
Hello All,
I have a textbox, panel and save button...this is in relation to connecting a server
I need to do is...whenever user clicks save button....it has to store all info in a text file in below format
1.Code Sent : (text in textbox) time
Code Recieved: Text that comes in Panel and Time
<br><br>
2.Code Sent : (text in textbox) time
Code Recieved: Text that comes in Panel and Time
and so on....basically a logfile with all details in above format how do I do that?
Member
7 Points
173 Posts
Re: saving all data in textfile
Sep 05, 2016 11:54 PM|fazioliamboina|LINK
My.computer.filesystem.writealltext(server.mappath("~\App_Data\Logs\Logfile.txt"), environment.newline & "a line to log", true)
it is recommended to chunk logfiles to new files every hour.
Contributor
2550 Points
1056 Posts
Re: saving all data in textfile
Sep 06, 2016 02:31 AM|Deepak Panchal|LINK
Hi Lexi85,
you can try to use code below to write the data from textbox to text file.
it will give you output like below.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.