Book Image

Unity Game Development Scripting

By : Kyle D'Aoust
Book Image

Unity Game Development Scripting

By: Kyle D'Aoust

Overview of this book

Table of Contents (17 chapters)
Unity Game Development Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.