Hi,
i use C# and the FileStream class, but i can’t get it to run. Each time i want to save a file i get the following error message:
UnauthorizedAccessException: Access to the path “/quicksave.txt” is denied.
System.IO.FileStream…ctor (System.String path, FileMode mode)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode)
GlobalData.SaveLevel ()
StartScreen.OnButtonPauseSave ()
StartScreen+TouchInterface.OnEnded (Int32 fingerId, Vector2 pos)
TouchControl.Update ()
StartScreen.Update ()
(Filename: Line: -1)
this is my code:
public void SaveLevel()
{
BackupGameData();
FileStream fs = new FileStream( quickSavename, FileMode.Create );
XmlSerializer xmlSer = new XmlSerializer( typeof( GameData ) );
xmlSer.Serialize( fs, gameData );
fs.Close();
}
public void LoadLevel()
{
FileStream fs = new FileStream( quickSavename, FileMode.Open );
XmlSerializer xmlSer = new XmlSerializer( typeof( GameData ) );
gameData = (GameData)xmlSer.Deserialize( fs );
fs.Close();
RestoreGameData();
}
I know to use the PlayerPrefs class to store information, but i feel more comfortable to use load and save files by my own.
What should i do?
Thanks