I am trying to write a program that creates dynamically named .csv files that must either be restored or deleted at a later launch date. I am trying to do the following:
I would like to run an algorithm that will detect if any of these file types exist. For example, if I dynamically named a file something like foobar ##. Csv C ##, indicating the number that is dynamically generated and added to the file name, I would like to find if any foobar ## file exists. Csv regardless of used number. Normally I would use a line of code:
NSString *dataFileName = [[self documentPath] stringByAppendingPathComponent:@"foobar01.csv"];
For the moment, I just use a loop that loops through each value cyclically and sends bool if it is found, but I know that this is not the best practice, since it limits the possible file name numbers that the user can use. Any insight into how I can use some kind of template for a search like this would be greatly appreciated.
In addition, I would like to create a method that will delete any .csv files found by the program, but I assume that the method used to solve the above algorithm can also be used to delete.
source share