在软件开发过程中发现一些数据用数据库存储很不方便,除此之外,数据库的安装也是一件很麻烦的事。于是就想到了利用文件来保存软件运行过程中的数据。然后发现了FileHelpers。通过它可以很方便的对文件中的数据进行读写。
FileHelpers是一个免费且易于使用的.NET库,用于从文件,字符串或流中的固定长度或分隔记录中导入或导出数据。
您可以通过简单地描述映射到每个记录的类,然后将您的文件作为强类型.NET数组读取或写入来强类型化您的平面文件(固定或分隔)。
该库还支持从不同的数据存储类型(如Excel,Access,SqlServer等)导入或导出数据。
FileHelpers is a free and easy to use .NET library to import or export data from fixed length or delimited records in files, strings or streams.
You can strongly type your flat file (fixed or delimited) by simply describing a class that maps to each record and later read or write your file as a strongly typed .NET array.
The library also has support to import or export data from different data storage types like Excel, Access, SqlServer, etc.
官方文档及示例代码已经很详细的介绍了该项目的使用方法,在这里就不过多叙述。
github地址:https://github.com/MarcosMeli/FileHelpers
官网:https://www.filehelpers.net/