yellowfeather / DbfDataReader

DbfDataReader is a small fast .Net Core library for reading dBase, xBase, Clipper and FoxPro database files
MIT License
134 stars 61 forks source link

Issue when reading a column of type "MEMO" with UWP App #67

Closed Furtif78 closed 3 years ago

Furtif78 commented 4 years ago

Works like a charm for many dbf Foxpro files. But, I am having an issue when reading files which had a column type of "Character" if the length> 255. dbf file and ScreenShot.zip

Error message : Exception levée : 'System.IndexOutOfRangeException' dans DbfDataReader.dll Une exception non gérée du type 'System.IndexOutOfRangeException' s'est produite dans DbfDataReader.dll Index was outside the bounds of the array.

Same issue with : https://github.com/yellowfeather/dbf

MarkPflug commented 3 years ago

@Furtif78 Where did this file originate?

It appears it might have some custom extension. FoxPro 9 won't open it, and that's the only software I have for working with .dbf files. Looking at the contents of the file, there are two bytes in the header at offset 0x1a that contain 0x24 0x40. This space is "reserved" according to this document. In all other files I've looked at, these are zero filled. I wonder if these indicate the extension.

Regardless of that, it appears that a fix would be easy. For data type 'C' (character) columns, this file is using both the fieldLength and decimalCount bytes together to encode the fieldLength as an int16.

I don't own this project, so I won't be fixing it here. I was looking for esoteric examples as I'm working on my own library for working with dbf files, primary with respect to GIS shape file data.

Anyway, hope my analysis is helpful at least.

Furtif78 commented 3 years ago

Hi, I have now more details. First It's an UWP app. It works like a charm for all dbf Foxpro files if there is no Memo field. var dbfTable = new DbfTable(localFile.Path, encoding); using (dbfTable) { DbfHeader header = dbfTable.Header; infos.Add($"Records: {header.RecordCount}"); infos.Add($"{header.VersionDescription}"); infos.Add($"Memo File: {dbfTable.Memo != null}"); } in this case Header is ok except Memo which is always "No" end if I try to read data to a such file then I have a null Exception.

In this case WPF yellowfeather solution is working : https://github.com/yellowfeather/dbf So I don't understand what happened !

chrisrichards commented 3 years ago

Did you ever find out what was happening with this?

Furtif78 commented 3 years ago

Unfortunately not

Furtif78 commented 3 years ago

I use DbfDataReader for an UWP app. Thanks for this correction but unfortunately for me versions after 0.5 are not compatible with UAP v10.0.18362