Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method only for reading metadata. Fix for reading large memo-files. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion dBASE.NET/Dbf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ public void Read(string path)
}
}

/// <summary>
/// Opens a DBF file, reads only database description and fields descriptors, and then closes the file.
/// </summary>
/// <param name="path">The file to read.</param>
public void ReadMetadata(string path)
{
using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read))
using (BinaryReader reader = new BinaryReader(stream))
{
ReadHeader(reader);
ReadFields(reader);
}
}

/// <summary>
/// Creates a new file, writes the current instance to the file, and then closes the file. If the target file already exists, it is overwritten.
/// </summary>
Expand Down Expand Up @@ -142,7 +156,7 @@ private static byte[] ReadMemos(string path)
FileStream str = File.Open(memoPath, FileMode.Open, FileAccess.Read);
BinaryReader memoReader = new BinaryReader(str);
byte[] memoData = new byte[str.Length];
memoData = memoReader.ReadBytes((int)str.Length);
memoReader.Read(memoData, 0, memoData.Length);
memoReader.Close();
str.Close();
return memoData;
Expand Down