What is the best way to copy records in two different ES3Settings

Discussion and help for Easy Save 3
Post Reply
xuzhuoxi
Posts: 6
Joined: Wed Aug 04, 2021 10:09 am

What is the best way to copy records in two different ES3Settings

Post by xuzhuoxi »

I use this way to copy records in two settings:

private static void CopyTo(ES3Settings source, ES3Settings target)
{
var keys = ES3.GetKeys(source);
for (var index = keys.Length - 1; index >= 0; index--)
{
var key = keys[index];
var value = ES3.Load(key, source);
if (null == value)
{
continue;
}

ES3.Save(key, value, target);
}
}

but, I don't think it is a good way.

and, if I need to override, the best way is?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: What is the best way to copy records in two different ES3Settings

Post by Joel »

Hi there,

If you're just wanting to be able to copy a file, you can use the ES3.CopyFile method.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
xuzhuoxi
Posts: 6
Joined: Wed Aug 04, 2021 10:09 am

Re: What is the best way to copy records in two different ES3Settings

Post by xuzhuoxi »

The location of the two ES3Settings is different.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: What is the best way to copy records in two different ES3Settings

Post by Joel »

Hi there,

The ES3.CopyFile method also accepts two different settings, in the same way as your method.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
xuzhuoxi
Posts: 6
Joined: Wed Aug 04, 2021 10:09 am

Re: What is the best way to copy records in two different ES3Settings

Post by xuzhuoxi »

en...i just want to find the best way to copy data in two different location. And the method "ES3.CopyFile" is forbidden:

if (oldSettings.location != newSettings.location)
throw new InvalidOperationException("Cannot copy file from " + oldSettings.location + " to " + newSettings.location + ". Location must be the same for both source and destination.");

at ES3.cs line 903
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: What is the best way to copy records in two different ES3Settings

Post by Joel »

Apologies, I misunderstood your comment as meaning you were saving from two different paths.

In your case you can simply do the following:

Code: Select all

ES3.SaveRaw( ES3.LoadRawBytes(oldSettings), newSettings );
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
xuzhuoxi
Posts: 6
Joined: Wed Aug 04, 2021 10:09 am

Re: What is the best way to copy records in two different ES3Settings

Post by xuzhuoxi »

This is what i want. Thanks.
Post Reply