# FolderService can't find existing folder

**URL:** <https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249>\
**Category:** Questions\
**Tags:** litium-6\
**Created:** [December 9, 2019, 8:21am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249 "2019-12-09T08:21:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [December 9, 2019, 8:21am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249/1 "2019-12-09T08:21:51Z")

</div>

Hello,  
We have an application where we recently upgraded from Litium 5 to Litium 6 and we are re-writing some of the media folder logic.  
this is the code we have:

```auto
folderName = "10606-214";
var folder = _folderService.Get(folderName);
if (folder == null)
{
 var newFolder = new Folder(parentFolder.FieldTemplateSystemId, folderName)
            {
                ParentFolderSystemId = parentFolder.SystemId
            };
            _folderService.Create(newFolder);
}

```

This will throw an exception:  
`{"Validation error for Folder(SystemId: 6a65c3b7-b978-4d98-a113-88159a5b351e), _nameInvariantCulture: 'There is already a folder named '10606-214''."}`

Why doesnt folderservice return a result when the folder exists?

Litium version: 6.3.6

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [December 9, 2019, 8:54am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249/2 "2019-12-09T08:54:25Z")

</div>

The folder service can search either by Guid or by id, while the validation checks that a folder with the same name doesn’t exist under the same parent folder.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 9, 2019, 9:20am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249/3 "2019-12-09T09:20:28Z")

</div>

Check your DB tables for any wrong values.

---

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [December 9, 2019, 9:54am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249/4 "2019-12-09T09:54:37Z")

</div>

Yes my bad. However in Litium 5 an ID field doesnt exist in MediaArchive\_Folder and we get everything by name. Shouldn’t that name be converted to ID when running the upgrade script to Litium 6?  
Either way we have found a solution to the problem.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [January 6, 2020, 9:54am UTC](https://forum.litium.com/t/folderservice-cant-find-existing-folder/1249/5 "2020-01-06T09:54:41Z")

</div>

Closed on January 6, 2020, 9:54am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
