Adeotek.dBASE.NET 1.4.1

dotnet add package Adeotek.dBASE.NET --version 1.4.1                
NuGet\Install-Package Adeotek.dBASE.NET -Version 1.4.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Adeotek.dBASE.NET" Version="1.4.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Adeotek.dBASE.NET --version 1.4.1                
#r "nuget: Adeotek.dBASE.NET, 1.4.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Adeotek.dBASE.NET as a Cake Addin
#addin nuget:?package=Adeotek.dBASE.NET&version=1.4.1

// Install Adeotek.dBASE.NET as a Cake Tool
#tool nuget:?package=Adeotek.dBASE.NET&version=1.4.1                

AdeoTEK dBASE.NET

.NET

Read and write DBF files with .NET

Adeotek.dBASE.NET is a .NET (netstandard2.1) class library used to read FoxBase, dBASE III and dBASE IV .dbf files. Data read from a file is returned as a list of typed fields and a list of records. This library is useful to add data import from dBASE sources to a .NET project.

This code has been tested against a number of dBASE files found in the wild, including FoxBase and dBASE III/IV files with and without memo files. A .NET unit test project is part of this repository and new test files may be added to it over time.

There is an article describing the dBASE file format.

Installing AdeoTEK dBASE.NET

AdeoTEK dBASE.NET is available from nuget:

  • Package manager:
PM> Install-Package Adeotek.dBASE.NET
  • .NET CLI:
> dotnet add package Adeotek.dBASE.NET
  • Paket CLI:
> paket add Adeotek.dBASE.NET

Opening a DBF file

using dBASE.NET;

dbf.Read("database.dbf");

This returns an instance of the Dbf class. With this, you can iterate over fields found in the table:

foreach(DbfField field in dbf.Fields) {
	Console.WriteLine(field.Name);
}

You can also iterate over records:

foreach(DbfRecord record in dbf.Records) {
	for(int i = 0;  i < dbf.Fields.Count; i++) {
		Console.WriteLine(record[i]);
	}
}

Count the records:

Console.WriteLine(dbf.Records.Count);

Working with memo files

When memo file accompanying the .dbf file is found (either .dbt or .fpt), with the same base name as the table file, then dBASE.NET will load the memo file's contents.

Writing a DBF file

To write DBF data, you can either create a new instance of Dbf, then create fields and records, or load an existing table and modify its fields or records.

This sample code creates a new table with a single character field, then saves the .dbf file:

dbf = new Dbf();
DbfField field = new DbfField("TEST", DbfFieldType.Character, 12);
dbf.Fields.Add(field);
DbfRecord record = dbf.CreateRecord();
record.Data[0] = "HELLO";
dbf.Write("test.dbf", DbfVersion.VisualFoxPro);

Supported Field types

Code Field type .NET counterpart
C Character string String
D Date DateTime
I Integer Int32
L Logical Bool
M Memo String
N Numeric Double
T DateTime DateTime
Y Currency Float

Class diagram

Class diagram

yuml:

http://yuml.me/diagram/scruffy/class/edit/[Dbf]+->[DbfRecord], [Dbf]+->[DbfField], [DbfRecord]+->[DbfField], [Dbf]->[DbfHeader], [DbfHeader]^-[Dbf4Header]

Versions

  • Version 1.4.1: Target Framework changed from net6.0 to netstandard2.1 & small fixes
  • Version 1.4.0: Migration to .NET 6 & xUnit
  • Version 1.3.0: Migration to .NET 5.0 & Fix encoding UTF8 multi-byte characters
  • Version 1.2.2: Fix reading DbfField from file with invalid name.
  • Version 1.2.1: Fixed buffer overflow on write operation. Fixed trimming and padding on write operation. Performance improve on write operation.
  • Version 1.2.0: Sign assembly.
  • Version 1.1.0: Add support for custom character encoding
  • Version 1.0.0: Initial release

Credits

This project was initially forked from dBASE.NET by Independent Software, but at some point was migrated to a stand-alone repository.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.1 810 7/13/2022
1.4.0 513 4/13/2022
1.3.0 1,051 11/11/2020
1.3.0-preview.2 258 10/29/2020