Faster Saving and Loading using ES2Writer and ES2Reader

If you are looking for extra performance when saving and loading, or extra flexibility in general, then we advise that you use ES2Writer and ES2Reader. This is faster than making multiple ES2.Save and ES2.Load calls because it keeps the file open between calls.

Much like ES2.Save and ES2.Load, ES2Writer and ES2Reader can be used with Tags.

Before you start, it should also be noted that you should not open multiple ES2Readers or ES2Writers for the same file as this will cause unexpected behaviour.

Saving Tags using ES2Writer

To save data to a file, you create an ES2Writer using ES2Writer.Create and then call it’s Write methods to save data to the file. When you are finished writing to the file, you must then call the writer’s Save method which stores the data to the file.

Unless you are using the ES2Writer as part of a Using statement, you must call the writer’s Dispose method when you are finished with it.

C#

JS

Loading Tags using ES2Reader

To load data from a file, you create an ES2Reader using ES2Reader.Create and then call it’s Read methods to load data from the file.

You may also use the Self-assigning Read methods to load data straight into a Component.

Unless you are using the ES2Reader as part of a Using statement, you must call the reader’s Dispose method when you are finished with it.

C#

JS

The fastest way to save and load data is to load it in the same order as you saved it, without using tags. This is done in exactly the same way as the previous example, except we don’t specify a tag when saving and loading.

It is very important that you load the data in the same order as you saved it, otherwise you will receive errors at runtime.

Also note that when saving sequentially, we use Save(false) instead of Save() to tell Easy Save that we’re not using tags.

Saving to a File Sequentially

C#

JS

Loading from a File Sequentially

To load data from a file, you create an ES2Reader using ES2Reader.Create(filepath) and then call it’s Read() methods to load data from the file.

It is important that you load data in the same order that you saved it.

You may also use the Self-assigning Read methods to load data straight into a Component.

Unless you are using the ES2Reader as part of a Using statement, you must call the reader’s Dispose() method when you are finished with it.

C#

JS