# Create directory

**URL:** <https://forum.legato.io/t/create-directory/2504>\
**Category:** Legato Application Framework\
**Created:** [June 18, 2017, 10:55pm UTC](https://forum.legato.io/t/create-directory/2504 "2017-06-18T22:55:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheGod](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/thegod/32/252_2.png) [@TheGod](https://forum.legato.io/u/TheGod)\
**Post date:** [June 18, 2017, 10:55pm UTC](https://forum.legato.io/t/create-directory/2504/1 "2017-06-18T22:55:10Z")

</div>

Hi,  
I want to create directory, but system allows me to do it, only when in my .adef file sandboxed: false.

I have got in .adef :  
requires:  
{  
dir:  
{  
/mnt/userrw /  
}  
}

my .c file  
le\_result\_t Err = le\_dir\_Make(“/mnt/userrw/TestDir”, S\_IRUSR | S\_IWUSR);  
if(Err == LE\_DUPLICATE)  
{  
//System creates folder “/mnt/userrw/TestDir” but instead of Err == LE\_OK  
//I have got Err == LE\_DUPLICATE which is weird.  
}

I am going to store data in files located in the folder, so I have to have permission to create/read/write files there.

Questions:

1. Do I have to have sandboxed:false? If not what should I change in my program to create dir.
2. Which folder should I use for my data storage?
3. Why system returns LE\_DUPLICATE instead of LE\_OK

Thanks

---

<div class="post-metadata">

**Author:** ![raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@raf](https://forum.legato.io/u/raf)\
**Post date:** [June 19, 2017, 1:08am UTC](https://forum.legato.io/t/create-directory/2504/2 "2017-06-19T01:08:00Z")

</div>

Hi @TheGod,

1. I believe you need to run the app unsanboxed in order to create new directories.  
See my post here: [Unable to make new directories within Legato app - #3 by raf](http://forum.legato.io/t/unable-to-make-new-directories-within-legato-app/2357/3)  
Having `sandboxed: false` was the only way it worked.

2. 

- For persistent data storage:  
I’ve used the same path and mounted an SD card at `/mnt/userrw/sd`.  
If you are going to be storing lots of files or doing lots of write/erase operations on the module’s non-volatile Flash memory, be conscious of Flash wear (finite write/erase cycles - typically 100000). You may want to consider external memory.

- For non-persistent data storage (wiped on power cycle):  
Use `/tmp` - this is mapped to the module’s RAM so there’s no concern over Flash wear here.

1. See: [le\_dir.h File Reference - Legato Docs](http://legato.io/legato-docs/latest/le__dir_8h.html#a7ac7d25b67f2e47127084677626d5344)  
`le_dir_Make` will return `LE_DUPLICATE` if the directory already exists. Try using `le_dir_MakePath` instead.

Raf
