# Check for new files addition and index them as an attachment

**URL:** <https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626>\
**Category:** Elasticsearch\
**Created:** [May 10, 2016, 9:15am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626 "2016-05-10T09:15:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [May 10, 2016, 9:15am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/1 "2016-05-10T09:15:32Z")

</div>

Is there any plugin or method to check if any new files(either doc or pdf or ppt) are added to a particular folder and if added, they should be indexed to the ES server as an attachment. (not looking for a console application which does the feeder job)  
TIA 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 10, 2016, 3:39pm UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/2 "2016-05-10T15:39:27Z")

</div>

That was the goal of [https://github.com/dadoonet/fscrawler](https://github.com/dadoonet/fscrawler)

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 7, 2016, 2:14am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/3 "2016-06-07T02:14:00Z")

</div>

I'm using FilesSystemWatcher of .NET for the changes in the folder and indexing the documents. But if the document is open or being modified , it is throwing an error while attaching . How can I ignore the files which are open or being modified and take the older version of the document?

```
try
            {
                Attachment attach = new Attachment
                {
                    Name = Path.GetFileNameWithoutExtension(file),
                    Content = Convert.ToBase64String(File.ReadAllBytes(file)),
                    ContentType = Path.GetExtension(file)
                };

                doc = new Document()
                {
                    Title = Path.GetFileNameWithoutExtension(file),
                    FilePath = Path.GetFullPath(file), 
                    CreatedDate = DateTime.Now,
                    File = attach
                };
            }
            catch (IOException e) //it is going into this exception if the file is open
            {
                Console.WriteLine("A Exception Occurred While Attaching :" + e);
            }
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 7, 2016, 5:50am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/4 "2016-06-07T05:50:12Z")

</div>

IMO it's a .Net question and not related to Elasticsearch.  
Or you may want to ask in Clients list?

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 7, 2016, 6:18am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/5 "2016-06-07T06:18:22Z")

</div>

> [@dadoonet](#):
>
> Or you may want to ask in Clients list?

what is clients list?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 7, 2016, 6:32am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/6 "2016-06-07T06:32:28Z")

</div>

Sorry. I meant: [https://discuss.elastic.co/c/development](https://discuss.elastic.co/c/development)

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 8, 2016, 12:58am UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/7 "2016-06-08T00:58:30Z")

</div>

okok. Thanks David.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:45pm UTC](https://discuss.elastic.co/t/check-for-new-files-addition-and-index-them-as-an-attachment/49626/8 "2017-07-05T22:45:29Z")

</div>


