Question: I'm using MongoDB driver in C#, and store video files using GridFS.  

I store the files continuously like recording a stream and once in a while (might be in middle of writing process) I ask to "play" a file.  

In some cases, at that part of playing the file there's a problem:  

1. the relevant GridFS file stream is opened.  

2. data read ok.  

3. GridFS file stream is closed -> throws WriteConcernException with the following details: 

```
WriteConcern detected an error 'E11000 duplicate key error index:
ElSightRecs.fs.chunks.$files_id_1_n_1  dup key: { :
ObjectId('536243c4c449203a24a8f3b2'), : 2656 }'. 
(Response was { "err" : "E11000 duplicate key error index: 
ElSightRecs.fs.chunks.$files_id_1_n_1  dup key: { : 
ObjectId('536243c4c449203a24a8f3b2'), : 2656 }", "code" : 11000, "n" : 0,
"connectionId" : 1111, "ok" : 1.0 }).

```

`

why do i get any write error when all I'm doing is closing the file stream?

Answer: 
Shouldn't it be?

```
var d = value.FirstOrDefault(x => String.Equals(x.Culture, Thread.CurrentThread.CurrentCulture.Name, StringComparison.InvariantCultureIgnoreCase));

```
Your issue is here:

```
var d ... x.Culture == Thread.CurrentThread.CurrentCulture.Name

```

This evaluates to `true`, so `string.Equals` where it is used yields unexpected results.

So the right code:

```
var d = value.FirstOrDefault(x => String.Equals(x.Culture, Thread.CurrentThread.CurrentCulture.Name, StringComparison.InvariantCultureIgnoreCase));

```