internal GridStream(
      Collection collection, 
      string name, 
      Doc fileInfo, 
      FileAccess access)
        {
            Contract.Requires(fileInfo != null);
              _collection = collection;
              _chunks = _collection.ChunkCollection();
              _fileInfo = new FileInfo(fileInfo, _collection);

              long rem;
              _totalChunks = (int)Math.DivRem(_fileInfo.Length, _fileInfo.ChunkSize, out rem);
              _totalChunks = rem > 0 ? _totalChunks + 1 : _totalChunks;
              _chunks.CreateIndex(new Index { { "files_id", Mongo.Dir.Asc }, { "n", Mongo.Dir.Asc } }, true);
              LoadChunk(0);
              _position = 0L;
              switch (access)
              {
            case FileAccess.Read:
              _canRead = true;
              break;
            case FileAccess.ReadWrite:
              _canRead = true;
              _canWrite = true;
              break;
            case FileAccess.Write:
              _canWrite = true;
              break;
              }
              _canSeek = true;
        }