# File syntax for subdirectory

**URL:** https://discourse.processing.org/t/file-syntax-for-subdirectory/5200
**Category:** Beginners
**Created:** [November 4, 2018, 10:42pm UTC](https://discourse.processing.org/t/file-syntax-for-subdirectory/5200 "2018-11-04T22:42:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [November 4, 2018, 10:42pm UTC](https://discourse.processing.org/t/file-syntax-for-subdirectory/5200/1 "2018-11-04T22:42:32Z")

</div>

I use creatWriter to output to a file.  
it works for the first level dircetory  
example: createWriter("c:/main "+string);

so i created a c:/main/reports

but when i try to output to that sub directory it just writes it to the c:/main  
example: createWriter("c:/main/reports "+string);

What’s wrong? What is the syntax for file strings sub directory access?  
Can i access subdirectories directly with file strings?  
Can i go more than 1 directory deep?  
Thks

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 4, 2018, 11:17pm UTC](https://discourse.processing.org/t/file-syntax-for-subdirectory/5200/2 "2018-11-04T23:17:18Z")

</div>

( -a- make sure the user has write privileges there )  
-b- if

> createWriter("c:/main/reports "+string);

creates a file in  
c:/main  
the filename might be  
reports and my file name in string variable  
try

```auto
 createWriter("c:/main/reports/"+string);

```

or can also try a file dialog

> **[selectFolder() / Reference](https://processing.org/reference/selectFolder_.html)**
>
> Opens a platform-specific file chooser dialog to select a folder. After the selection is made, the selection will be passed to the 'callback' function. If the dialog is closed or canceled, null will b…

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [November 5, 2018, 2:15am UTC](https://discourse.processing.org/t/file-syntax-for-subdirectory/5200/3 "2018-11-05T02:15:41Z")

</div>

You might need to create the folders if they don’t exist. For instance, you can call mkdir from the File class, a class provided by the JRE: [https://docs.oracle.com/javase/7/docs/api/java/io/File.html](https://docs.oracle.com/javase/7/docs/api/java/io/File.html)

Kf
