Save datatable as user setting

后端 未结 3 1043
你的背包
你的背包 2021-01-15 00:37

I currently try to save a datatable as a user setting using die old \"properties.settings.default.save()\" method.

It does not work. My Settings don\'t get saved. ho

3条回答
  •  暖寄归人
    2021-01-15 01:20

    You can save the DataTable as an XML string to an ordinary String setting, like this:

     StringWriter writer = new StringWriter();
     table.WriteXml(writer);
     Settings.Default.TableXml = writer.ToString();
    

    You can then load it from the setting like this:

     StringReader reader = new StringReader(Settings.Default.TableXml);
     table.ReadXml(reader);
    

提交回复
热议问题