I have a very simple app that creates a text file (after a button click) and sends it to a certain email address(after another button click). I want to add the ability to change the name of the text file that is created based on how many times the file was sent, or i.e. how many times the app successfully ran till the end. Currently, the name of the text file is fixed.
My idea:
I am thinking of adding a check on start-up of the app to see if another text file exists, lets called it Counter.txt. This will contain the number of times the 'send' button was clicked. If the file doesn't exist, then it will create it and append the number 0. Every time the 'send' button is clicked, it will open Counter.txt and increment that number. Also on a 'send' click, it will email the main textfile that I want to send and adjust the name by appending the number from Counter.txt to it.
I am not sure if this is the best or most efficient method, so would appreciate other suggestions to achieve this. Thanks.