N
N
noytmant2020-02-03 12:29:12
JSON
noytmant, 2020-02-03 12:29:12

Saving config to JSON?

In general, I created a program in which profiles are loaded into a combobox from a text document, its contents:
5e37e4dad76a3541168419.png
As a result, we have 2 lines in the combobox, well, it's logical.
Further below the combobox there are 2 fields, I enter the data there, and press the save button. The JSON config was saved easily, without any problems:

JsonSerializer jsonSerializer = new JsonSerializer();
            TextWriter writer = new StreamWriter("DataProfiles\\" + this.namez + ".json");
            jsonSerializer.Serialize(writer, this);
            writer.Close();

this.namez is the name of the profile, i.e. 11111 or 22222, there are two of them.
But after I close the program to open it again, the config is loaded (to fill in the fields with the data that I entered).
This error appears:
5e37e5e5df31b858329100.jpeg
Code for loading the config:
FileStream fileStreamz = new FileStream("DataProfiles\\" + profiles3[0] + ".json", FileMode.Open);
                        string jsoncon = JsonConvert.SerializeObject(fileStreamz);
                        dtprof = (Dataprofiles)JsonConvert.DeserializeObject(jsoncon);
                        fileStreamz.Close();

What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-02-03
@yarosroman

Please show the json code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question