Read DBF file without driver or OLE
// 2014 fix error with number, decimal.
// This is the file header for a DBF. We do this special layout with everything
// packed so we can read straight from disk into the structure to populate it
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
private struct DBFHeader
{
public byte version;
public byte updateYear;
public byte updateMonth;
public byte updateDay;
public Int32 numRecords;
public Int16 headerLen;
public Int16 recordLen;
public Int16 reserved1;
public byte incompleteTrans;
public byte encryptionFlag;
public Int32 reserved2;
public Int64 reserved3;
public byte MDX;
public byte language;
public Int16 reserved4;
}
// This is the field descriptor structure. There will be one of these for each column in the table.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
private struct FieldDescriptor
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
public string fieldName;
public char fieldType;
public Int32 address;
public byte fieldLen;
public byte count;
public Int16 reserved1;
public byte workArea;
public Int16 reserved2;
public byte flag;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
public byte[] reserved3;
public byte indexFlag;
}
Link update 25/03/2014
Download http://downloads.ziddu.com/download/23644473/ParseDBF.rar.html
No comments:
Post a Comment