// Saves a file with the textToSave using a path private void SaveFileUsingPath(string path) { // get the data to save _textToSave = savesManager.CompileSaveData(); // Make sure path and _textToSave is not null or empty if (!String.IsNullOrEmpty(path) && !String.IsNullOrEmpty(_textToSave)) { BinaryFormatter bFormatter = new BinaryFormatter(); // Create a file using the path FileStream file = File.Create(path); // Serialize the data (textToSave) bFormatter.Serialize(file, _textToSave); // Close the created file file.Close(); } else { Debug.Log("Invalid path or empty file given"); } }