c# streamwriter delete line code example
Example: how clear all line in text file and write new string in c#
if (File.Exists(ModuleListPath))
{
File.WriteAllText(ModuleListPath, String.Empty);
}
foreach (var item in list)
{
using (StreamWriter stream = new StreamWriter(ModuleListPath,true))
{
try
{
stream.WriteLine(item);
}
catch
{
trow;
}
}
}