コード例 #1
0
ファイル: DBFReader.cs プロジェクト: msruzy/hydronumerics
        private void InitializeForReading()
        {
            string currentdir = System.IO.Directory.GetCurrentDirectory();

            _dbfPointer = ShapeLib.DBFOpen(_filename, "rb");

            _data = new DataTable();

            _columns = new Dictionary <string, DBFEntry>();

            int NoOfColumns = ShapeLib.DBFGetFieldCount(_dbfPointer);

            NoOfEntries = ShapeLib.DBFGetRecordCount(_dbfPointer);

            for (int i = 0; i < NoOfColumns; i++)
            {
                DBFEntry      E    = new DBFEntry();
                StringBuilder Name = new StringBuilder();

                E._dbfType = ShapeLib.DBFGetFieldInfo(_dbfPointer, i, Name, ref E._width, ref E._decimals);
                E.name     = Name.ToString();
                E._index   = i;

                //Find the corresponding .NET Type
                switch (E._dbfType)
                {
                case ShapeLib.DBFFieldType.FTDate:
                    E._dotNetType = typeof(DateTime);
                    break;

                case ShapeLib.DBFFieldType.FTDouble:
                    E._dotNetType = typeof(double);
                    break;

                case ShapeLib.DBFFieldType.FTInteger:
                    E._dotNetType = typeof(int);
                    break;

                case ShapeLib.DBFFieldType.FTLogical:
                    E._dotNetType = typeof(bool);
                    break;

                case ShapeLib.DBFFieldType.FTString:
                    E._dotNetType = typeof(string);
                    break;

                case ShapeLib.DBFFieldType.FTInvalid:
                default:
                    E._dotNetType = typeof(object);
                    break;
                }

                _columns.Add(E.name, E);
                _data.Columns.Add(E.name, E._dotNetType);
            }
        }
コード例 #2
0
ファイル: DBFReader.cs プロジェクト: XiBeichuan/hydronumerics
    private void InitializeForReading()
    {

      string currentdir = System.IO.Directory.GetCurrentDirectory();

      _dbfPointer = ShapeLib.DBFOpen(_filename, "rb");

      _data = new DataTable();

      _columns = new Dictionary<string, DBFEntry>();

      int NoOfColumns = ShapeLib.DBFGetFieldCount(_dbfPointer);
      NoOfEntries = ShapeLib.DBFGetRecordCount(_dbfPointer);

      for (int i = 0; i < NoOfColumns; i++)
      {
        DBFEntry E = new DBFEntry();
        StringBuilder Name = new StringBuilder();

        E._dbfType = ShapeLib.DBFGetFieldInfo(_dbfPointer, i, Name, ref E._width, ref E._decimals);
        E.name = Name.ToString();
        E._index = i;

        //Find the corresponding .NET Type
        switch (E._dbfType)
        {
          case ShapeLib.DBFFieldType.FTDate:
            E._dotNetType = typeof(DateTime);
            break;
          case ShapeLib.DBFFieldType.FTDouble:
            E._dotNetType = typeof(double);
            break;
          case ShapeLib.DBFFieldType.FTInteger:
            E._dotNetType = typeof(int);
            break;
          case ShapeLib.DBFFieldType.FTLogical:
            E._dotNetType = typeof(bool);
            break;
          case ShapeLib.DBFFieldType.FTString:
            E._dotNetType = typeof(string);
            break;
          case ShapeLib.DBFFieldType.FTInvalid:
          default:
            E._dotNetType = typeof(object);
            break;
        }

        _columns.Add(E.name, E);
        _data.Columns.Add(E.name, E._dotNetType);
      }
    }