internal DbfTableParametersReadOnly(DbfTableParameters parameters) { encoding = parameters.encoding; openMemo = parameters.openMemo; strictHeader = parameters.strictHeader; tableType = parameters.tableType; memoType = parameters.memoType; indexType = parameters.indexType; memoTerminators = parameters.memoTerminators; openMode = parameters.openMode; }
protected DbfTable(Stream stream, DbfTableParameters parameters) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw ExceptionFactory.CreateArgumentException("stream", "The stream does not allow reading (CanRead property returns false)."); } if (!stream.CanSeek) { throw ExceptionFactory.CreateArgumentException("stream", "The stream does not allow reading (CanSeek property returns false)."); } this._stream = stream; this.parameters = parameters; RefreshHeaderInfo(); // if (this.parameters.encoding == null) { this.parameters.encoding = ReadDbfHeader_Encoding(_header.codepageCode); if (this.parameters.encoding == null) { throw new Exception("DbfTable: the DBF file don't contains codepage information!"); } } this._columns = ReadDbfColumns(_stream, this.parameters.encoding, _header.newHeaderStructure, this.parameters.openMemo); // int calcLen = _header.firstRecordPosition + (_header.recCount * _header.rowLength) + 1; if ((stream.Length < calcLen - 1) || (stream.Length > calcLen + 1)) { // dBase & Clipper different (There is or there isn't a 0x1F character at end of DBF data file . throw ExceptionFactory.CreateArgumentOutOfRangeException("DBF table", "Datafile length error! [got: {0} expected: {1}]", stream.Length, calcLen); } }
/// <summary> /// Opens a table from the specified file. /// </summary> /// <param name="path">The file to be opened.</param> /// <returns>A table instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception> /// <exception cref="NotSupportedException">The dBASE table constains one or more columns of unsupported type.</exception> public static DbfTable Open(string path, DbfTableParameters parameters) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } var stream = new FileStream(path, FileMode.Open, parameters.fileAccess, parameters.fileShare); var dbfFile = new DbfTable(stream, parameters); dbfFile.dataFileName = path; if (dbfFile.isExistsMemoField && parameters.openMemo) { // If exist a memo field and it is opened from a file, so I can find DBT/FPT/etc. memo file too. dbfFile.JoinMemoFile(); } return(dbfFile); }
/// <summary> /// Opens a table from the specified stream. /// </summary> /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param> /// <returns>A table instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception> /// <exception cref="NotSupportedException">The dBASE table constains one or more columns of unsupported type.</exception> public static DbfTable Open(Stream stream, Encoding encoding = null, bool openMemo = true, StrictHeader?strictHeader = null, DbfTableType tableType = DbfTableType.Undefined) { var parameters = new DbfTableParameters(encoding, openMemo, strictHeader, tableType, null, null); return(new DbfTable(stream, parameters)); }
public static DbfTable Open(Stream stream, DbfTableParameters parameters) { return(new DbfTable(stream, parameters)); }
public static DbfTable Open(string path, DbfTableOpenMode openMode, Encoding encoding = null, bool?openMemo = null, StrictHeader?strictHeader = null, DbfTableType tableType = DbfTableType.Undefined) { DbfTableParameters parameters = new DbfTableParameters(openMode, encoding, openMemo, strictHeader, tableType); return(Open(path, parameters)); }