I'm new in programming, can you help me in this?, because everytime I run this it duplicates the data, now I want to replace or just update it, here is my code.. Thank you
StreamWriter writer = null;
StringBuilder strbuilder = null;
string dir = Application.StartupPath;
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
string path = Path.Combine(dir, "test.csv");
strbuilder = new StringBuilder();
strbuilder.Append("\n");
foreach (var a in listofuser)
{
strbuilder.Append(a.SystemUserID.ToString() + "," + a.FullName.ToString() + "," + a.Department.ToString() +","+ Environment.NewLine);
}
writer = new StreamWriter(path, true);
writer.Write(strbuilder);
writer.Close();
List<T>of some custom object), edit whatever you want to edit in that collection, and then write the whole thing back out to a new file (overwriting the original if you want).