Iterate through variables in project

I am hoping to iterate through all variables in a xaml and write their value dynamically into a configuration file (like .csv) so that my process can pick itself back up if it is knocked down at a point. I would then want to reverse this by reading the config and iterating through the variables to re-instantiate those variables with their last values.
Example:
for each(variable in project){
key = variable.name
value = variable.value
}
write to csv

Hi,

Is Serialization for persisting the Workflow instance’s state is what you are trying to achieve?

Arguments to be part of this?