StreamWriter – how not to clear existing text
StreamWriter has some options of usage. You can as add new text to an existing text in file, so and to clean existing text and add a new one.
The 6th option of usage StreamWriter is (string path, bool append, Encoding encoding)
To truncate data in a file, you should use something like this:
using (StreamWriter sw = new StreamWriter(cmdFilePath, false, Encoding.Default))
{
String presentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
sw.WriteLine(text);
sw.Close();
}
If you want to add new text to a file, use true instead of false:
using (StreamWriter sw = new StreamWriter(cmdFilePath, true, Encoding.Default))
{
String presentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
sw.WriteLine(resultCommands);
sw.Close();
}

PostgreSQL in Docker: when DBeaver lies (and psql saves the day)
SharePoint onPrem: Create ContentType with the specific ID
Send props from Child class component to Parent state component in React App