Error when viewing save data in File Editor

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
jrhee
Posts: 3
Joined: Sat May 16, 2015 2:01 am

Error when viewing save data in File Editor

Post by jrhee »

Hello,

Starting playing with ES2, looks great so far!

Ran into a problem with this test script:
public void Save()
	{
		using(ES2Writer writer = ES2Writer.Create("testSave.txt"))
		{
			writer.Write("AAA");
			writer.Save();
		}
	}
	public void Load()
	{
		using(ES2Reader reader = ES2Reader.Create("testSave.txt"))
		{
			Debug.Log (reader.Read<string>());
		}
	}
After saving, when I try to view the file contents under Assets > ES2 > File Editor, I'm getting the error:
Could not open file
This file does not contain data which is readable by Easy Save
Please make sure this file was created using Easy Save 2

The test string appears correctly in my console when I try to load. I'm on Win8, Unity 4.6.4 and ES 2.6.3.

Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error when viewing save data in File Editor

Post by Joel »

Hi there,

The File Editor can't read sequentially written data because the file contains no information on what data is actually inside the file. It can only read tagged data, so for your example to be readable in the File Editor you would need to do this instead:
public void Save()
  {
       using(ES2Writer writer = ES2Writer.Create("testSave.txt"))
      {
           writer.Write("AAA", "myTag");
            writer.Save();
      }
   }
   public void Load()
  {
       using(ES2Reader reader = ES2Reader.Create("testSave.txt"))
      {
           Debug.Log (reader.Read<string>("myTag"));
        }
   }
I've added a note to the docs page to clarify this.

All the best,
Joel
jrhee
Posts: 3
Joined: Sat May 16, 2015 2:01 am

Re: Error when viewing save data in File Editor

Post by jrhee »

Ah thanks, makes sense- thanks for the quick reply.

Noticing a related issue now where after the first save (where the save file is created), when I try to save again I get the following exception:

ES2InvalidDataException: Easy Save 2 Error: The file provided does not contain data that is readable by Easy Save. Please make sure that file was created by Easy Save.
ES2Reader.Next ()
ES2Reader.DeleteTags (ICollection`1 tags, .ES2Writer writer)
ES2Writer.Delete ()
ES2Writer.Save (Boolean checkForOverwrite)
ES2Writer.Save ()
GameMgr.Save () (at Assets/Scripts/GameMgr.cs:77)
GameMgr.Update () (at Assets/Scripts/GameMgr.cs:49)

Thanks,
John
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error when viewing save data in File Editor

Post by Joel »

Ahh, I think I can see what's causing this in your code.

When writing sequentially, you need to call writer.Save(false) rather than writer.Save().

All the best,
Joel
jrhee
Posts: 3
Joined: Sat May 16, 2015 2:01 am

Re: Error when viewing save data in File Editor

Post by jrhee »

Perfect, that did the trick- thanks again!
Locked