SaveLoad.Save C# (CSharp) 메소드

Save() 공개 메소드

public Save ( PlayerData, data ) : void
data PlayerData,
리턴 void
	public void Save(PlayerData data){
		BinaryFormatter bf = new BinaryFormatter ();
		FileStream file = File.Create (Application.persistentDataPath + "/Save.sav");

		bf.Serialize (file, data);
		file.Close ();
	}

Usage Example

예제 #1
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog SaveAs = new SaveFileDialog();

            SaveAs.Filter = "*.txt | *.txt"; // Only allows .xml formats to save to
            SaveAs.Title  = "Save Spreadsheet";

            if (SaveAs.ShowDialog() == DialogResult.OK) // Prompts the user to enter a new file name
            {
                try
                {
                    MainSave.Save(SaveAs.FileName, mainSS); // attempts to save the file
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Error - Could not save to File", MessageBoxButtons.OK);
                }
            }
        }
All Usage Examples Of SaveLoad::Save