//相信你们搜到这里的时候已经很明白自己的代码了,具体实现就不贴了,只贴关键代码 //这里引用gdal中读取属性字段转成string的函数,试过好几个版本均可以 //因为字段名可能是中文所以不能用字段名,不然会有乱码问题 [DllImport("gdal110.dll", EntryPoint = "OGR_F_GetFieldAsString", CallingConvention = CallingConvention.Cdecl)] public extern static System.IntPtr OGR_F_GetFieldAsString(HandleRef handle, int index); //调用gdal方法传入feature和属性位置的index IntPtr pStr = OGR_F_GetFieldAsString(OSGeo.OGR.Feature.getCPtr(myFeature), (int)fieldIndex); //然后调用.net的非托转托的marshal 把指针转换成变量 string s= Marshal.PtrToStringAnsi(pStr);
此处应有掌声。对了
Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES") 这里如果是NO的话 路径会是乱码
还有