I am saving data to a file-name using Stream writer but if i run the code for second time the same data is appended to the previous data but i would like to clear the old data a
You're passing true as the append parameter in the StringWriter constructor.
true
append
StringWriter
Second parameter here: new StreamWriter(StrFilePath,true) is set to true, which means append to file. Set that parameter to false and it will work.
new StreamWriter(StrFilePath,true)