For example I have a open file dialog, which opens a txt file.

When I press a specific button, it clears the whole text file.

How do I do that?