How can i save textbox data in .txt file
Please tell about below form how can i create new .txt file from below textbox..

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jitendra KumarRank #760 · 3K reputationPosted Mar 27, 2015, 7:16 AM EDT
{
string strLogFilePath = null;
if (System.IO.Directory.Exists("d:\\Log") == false)
{
System.IO.DirectoryInfo dirELogs = default(System.IO.DirectoryInfo);
dirELogs = System.IO.Directory.CreateDirectory("d:\\Log");
}
strLogFilePath = "d:\\Log\\Log_";
FileStream fs1 = default(FileStream);
StreamWriter sw = default(StreamWriter);
DataSet dsFile = new DataSet();
try
{
if (System.IO.File.Exists(strLogFilePath) == false)
{
fs1 = new FileStream(strLogFilePath, FileMode.Create);
sw = new StreamWriter(fs1);
sw.WriteLine(txt.text.Trim());
sw.WriteLine("-----------------------");
sw.Close();
fs1.Close();
}
else
{
fs1 = new FileStream(strLogFilePath, FileMode.Append, FileAccess.Write);
sw = new StreamWriter(fs1);
sw.WriteLine(txt.Text.Trim());
sw.WriteLine("-----------------------");
sw.Close();
fs1.Close();
}
}
}
Abhay ShankerRank #375 · 6.7K reputationPosted Mar 27, 2015, 10:23 AM EDT
http://stackoverflow.com/questions/16257388/saving-windows-form-listbox-to-a-text-file-c-sharp
Abhay ShankerRank #375 · 6.7K reputationPosted Mar 27, 2015, 10:23 AM EDT
http://stackoverflow.com/questions/16257388/saving-windows-form-listbox-to-a-text-file-c-sharp