Game Development Reference
In-Depth Information
Deleting our flat files
Next, we create a function that allows us to delete flat files. Add this function to your
script:
void DeleteFile(string file = "")
{
File.Delete(sDirectory + file);
}
To delete a file, we use the
Delete
function within the
File
class. Before we delete
the file, we make sure that it actually exists using the
Exists
function within the
File
class. The file that we are deleting is the one that is set to our directory and filename
variables.