Ways to store data in .NET

前端 未结 4 1718
臣服心动
臣服心动 2021-01-01 06:59

I am looking for ways to store data in a Windows Forms application in .NET. I want to make the input data of a system persistent, so when I close my program and open it agai

相关标签:
4条回答
  • 2021-01-01 07:15

    There are dozens of different ways to store data. It completely depends on what data. Is it:

    • Just a couple of configuration values? Use the built-in Settings library.
    • Machine-wide configuration? Use the registry.
    • Transactional? Use a relational database.
    • Related but not transactional? Use a lightweight database like SQLite or SQLCE.
    • Structured but not related? Use XML or JSON files.
    • Somewhat structured and high in volume? Use a NoSQL solution like MongoDB.

    And so on... there are different solutions for every storage requirement and many projects make use of more than one at a time.

    0 讨论(0)
  • 2021-01-01 07:25

    An easy way would be to make use of XML.

    Using XML in C# in the simplest way

    Read/Write Xml document with FileStream

    0 讨论(0)
  • 2021-01-01 07:40

    If your data is not mission critical (e.g. user preferences), you could just serialise your objects to file, and de-serialise them next time the app is loaded.

    0 讨论(0)
  • 2021-01-01 07:40

    Examples? Do your homework yourself :)

    Anyhow, possible ways are:

    • Registry.
    • Files. Like Microsoft Word does. Or like an ini file, like most games do for example for their settings
    • Databaase

    Which makes sense depends on what the application DOES and other scenarios around it. A fast answer is not really possible without knowing more.

    0 讨论(0)
提交回复
热议问题