I'm using ES3 and getting a KeyNotFoundException.
Code is like so:
using (ES3Reader reader = ES3Reader.Create(filename))
{
long dateTime = reader.Read<long>("myDateTime");
long gameTime = reader.Read<long>("myGameTime");
}
My save file looks like this:
{
"myDateTime" : {
"__type" : "long",
"value" : -8585468269062238189
},
"myGameTime" : {
"__type" : "long",
"value" : 655333938000000000
}
}
When I trace the parser, it seems like it's reading one key and value and then reads } } and closes the reader, disregarding the second property.
Maybe I'm doing it wrong? I've used ES2 for years and this approach worked fine before.
Using ES3 Reader key not found exception
Re: Using ES3 Reader key not found exception
Hi there,
ES3Reader/Write is now only used internally and should not be used, as it is unlikely to work how you expect.
Instead you should use caching if you want to benefit from making multiple reads/writes with a single I/O call, which is documented here:
https://docs.moodkie.com/easy-save-3/es ... rformance/
All the best,
Joel
ES3Reader/Write is now only used internally and should not be used, as it is unlikely to work how you expect.
Instead you should use caching if you want to benefit from making multiple reads/writes with a single I/O call, which is documented here:
https://docs.moodkie.com/easy-save-3/es ... rformance/
All the best,
Joel
Re: Using ES3 Reader key not found exception
Ah, that explains. Thanks.
One more question: How do I write the cache to a file?
ES3.StoreCachedFile() stores it to the default file.
ES3.StoreCachedFile("myfile"); says "FileNotFoundException: The file 'myfile' could not be stored because it could not be found in the cache.
Do I have to feed it ES3settings with a path set to the file I want? Do I have to create the file first? This all seems too much hassle to be the right way to do it, but after checking the guides, examples and tutorials, I couldn't figure out how to do this. Except copying the default file to the path I actually want using system IO, which doesn't seem like the way to do it either.
One more question: How do I write the cache to a file?
ES3.StoreCachedFile() stores it to the default file.
ES3.StoreCachedFile("myfile"); says "FileNotFoundException: The file 'myfile' could not be stored because it could not be found in the cache.
Do I have to feed it ES3settings with a path set to the file I want? Do I have to create the file first? This all seems too much hassle to be the right way to do it, but after checking the guides, examples and tutorials, I couldn't figure out how to do this. Except copying the default file to the path I actually want using system IO, which doesn't seem like the way to do it either.
Re: Using ES3 Reader key not found exception
Hi there,
The error you are getting is because there is no save data in the cache with that filename. I.e.
All the best,
Joel
The error you are getting is because there is no save data in the cache with that filename. I.e.
Code: Select all
var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("myKey", 123, "myFile.es3", settings);
// This will not throw an error.
ES3.StoreCachedFile("myFile.es3");
// This will throw an error.
ES3.StoreCachedFile();
// And so will this.
ES3.StoreCachedFile("DifferentFileName.es3");
Joel
Re: Using ES3 Reader key not found exception
I see, thanks! Got it working. I was confused by the paradigm, but it makes sense now.