我正在尝试使用 *.dbf (dBase IV) 文件从中获取一些所需的地理数据(shapefile)。
奇怪的是 dBase JET OleDb 4.0 提供者告诉我,没有这样的对象,但它确实存在!
证明:
http://s21.postimg.org/eaj4h91uv/image.png
源代码:
static void Test()
{
const string path = "C:\\buildings.dbf";
string conStr = String.Format("Provider = Microsoft.Jet.Oledb.4.0; Data Source = {0}; Extended Properties = \"dBase IV\"", Path.GetDirectoryName(path));
var connection = new OleDbConnection(conStr);
connection.Open();
var command = new OleDbCommand(string.Format("select NAME from {0}", Path.GetFileName(path)), connection);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var str = (string)reader["NAME"];
}
}
connection.Close();
}
static void Main()
{
try
{
Test();
}
catch (Exception exc)
{
Console.WriteLine(exc);
}
}