Erase and replace

Here is what I have at the moment

My.Computer.FileSystem.WriteAllText("C:\SaverSupreme\ScreeenFile.txt", lstTheme.SelectedItem, True)

This is ok, but what I want is when the user clicks a new SelectedItem from the listbox the old entry is erased and replaced with the new one.

I thought of Append but I think that only adds to what is already on file.



Answer this question

Erase and replace

  • fhunter

    Thanks for the Help and Advice.

  • kangalert

    indeed the append will do that, sorry, what exactly do you want to do remove the file or overwrite it

  • dpeeth

    By ommitting or setting the append argument to false the WriteAllText will overwrite the file with the new string...

    My.Computer.FileSystem.WriteAllText("C:\SaverSupreme\ScreeenFile.txt", lstTheme.SelectedItem)

    or

    My.Computer.FileSystem.WriteAllText("C:\SaverSupreme\ScreeenFile.txt", lstTheme.SelectedItem, False)



  • Erase and replace