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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Mar 27, 2015, 2:23 PM
http://stackoverflow.com/questions/16257388/saving-windows-form-listbox-to-a-text-file-c-sharp
Abhay ShankerPosted Mar 27, 2015, 2:23 PM
http://stackoverflow.com/questions/16257388/saving-windows-form-listbox-to-a-text-file-c-sharp
Jitendra KumarPosted Mar 27, 2015, 11:16 AM
{
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();
}
}
}