简体   繁体   English

从外部源向C#程序读取数据的最佳选择?

[英]Best option to read data from an external source to a C# program?

I have a C# program that needs to read in an store external data and store within the classes to be called upon by the program at various stages of the programs execution. 我有一个C#程序,需要读取存储外部数据并将其存储在要在程序执行的各个阶段中由程序调用的类中。 The storage of the data isn't a big issue as its only about 50 strings and it'll never be more than that so some structure like a dictionary (what I have been using) is perfect. 数据的存储不是一个大问题,因为它只有大约50个字符串,而且永远不会超过这个数目,因此像字典(我一直在使用)之类的某些结构是完美的。 The external data is basically user options that need to be changed from time to time by the person using the program 外部数据基本上是用户选项,使用该程序的人需要不时更改

There are two main requirements for the method of reading and storage the external data. 读取和存储外部数据的方法有两个主要要求。

1) The information has to be external. 1)信息必须是外部的。

2) The information has to be able to be changed with relative easy for people with absolutely no programming skills and very little IT skills in general. 2)对于那些完全没有编程技能并且通常只有很少IT技能的人,必须能够相对容易地更改信息。

So far I have come up with a few methods but they all have disadvantages to the point where I feel there might be a better option that I'm just not seeing? 到目前为止,我已经提出了一些方法,但是它们都具有一些缺点,以至于我觉得也许我没有看到更好的选择?

I have tried using a text file and simply using dilimiting characters to identify the data for example: optionName=OptionData 我尝试使用文本文件,而仅使用分隔字符来标识数据,例如: optionName=OptionData

I have tried using an excel file and using EPPlus to identify the data. 我尝试使用Excel文件并使用EPPlus来识别数据。 This makes it a lot less messy and I can use colours etc to make the spreadsheet easier to use. 这样可以减少混乱,并且我可以使用颜色等来简化电子表格的使用。

Both these methods fall with the same problem. 这两种方法都存在相同的问题。 The text file or excel file needs to be in the file directory for the code base and it could potentially get messy for the user to use and if there are multiple versions of the spreadsheet flying about it could be a problem. 文本文件或excel文件必须位于代码目录的文件目录中,并且可能使用户无法使用,并且如果电子表格存在多个版本,可能会出现问题。

Configuration files would be perfect if it wasn't for the second requirement. 如果不是第二个要求,配置文件将是完美的。

The last route that I have tried is using a self contained database, namely SQLite, this however falls under the same roof as the text and excel files I feel. 我尝试的最后一条路线是使用一个自包含的数据库,即SQLite,但这与我感觉到的文本和excel文件属于同一层楼。 However I am new to SQLite and maybe I'm wrong? 但是我是SQLite的新手,也许我错了?

Any ideas are greatly appreciated. 任何想法都将不胜感激。 I don't this is a very uncommon problem so maybe other people have faced and overcame this issue before? 我不是一个非常常见的问题,所以也许其他人以前曾经遇到并克服了这个问题?

Configuration files would be perfect if it wasn't for the second requirement 如果不是第二个要求,配置文件将是完美的

I Really hate to tell you, but whateve you come up with in a file IS a configuration file and your only way to make it easy to edit for someone with no respect for form is to write an editor and that will cost (time and money). 我真的很讨厌告诉您,但是您在文件中提出的只是配置文件,而使不尊重表单的人易于编辑的唯一方法是编写编辑器,这将花费大量的时间和金钱。 )。

I would not go with some sql program for that - on top, it will not solve the issue of having an editor. 我不会为此使用一些sql程序-最重要的是,它不会解决拥有编辑器的问题。

XML File, mapped to a class, plus a small winform based editor is as good as it gets. XML File映射到一个类,再加上一个基于Winform的小型编辑器,效果也不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM