# Unable to create file on USB drive

**URL:** <https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467>\
**Category:** General\
**Created:** [19 April 2022 01:43 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467 "2022-04-19T01:43:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.nodered.org/u/Kai)\
**Post date:** [19 April 2022 01:43 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/1 "2022-04-19T01:43:46Z")

</div>

Hi, anyone knows how to assign the permission to node-red in order to create file on USB drive?

 ![node-red_writefile](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0fb8805b8833187cae54e848eff346f6a14cb61d.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 April 2022 07:15 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/2 "2022-04-19T07:15:48Z")

</div>

Is the USB drive plugged into the same computer where node red is running?

What does the built-in help of the file node say about Windows paths?

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.nodered.org/u/Kai)\
**Post date:** [19 April 2022 07:55 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/3 "2022-04-19T07:55:06Z")

</div>

yup, the USB drive plugged into the same computer

and I'm trying to write a file to H:\ path

but the debug message said unable to create the directory due to denied of operation 😅

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 April 2022 08:01 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/4 "2022-04-19T08:01:37Z")

</div>

> [@Kai](#):
>
> but the debug message said unable to create the directory due to denied of operation 😅

Yeah but under the hood, without escaping backslashes, a file name of `h:data.json` is trying to be created - which is NOT permitted on windows.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/3011578c2789a97472d4b04f432b69dc36c9489a.png)

You didnt say but I assume you are now using `h:\\data.json` or even better, `h:/data.json`?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [19 April 2022 08:05 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/5 "2022-04-19T08:05:06Z")

</div>

So don't you need to make it:  
`H:\\data.json`?

Screenshots sometimes are painful to read.

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.nodered.org/u/Kai)\
**Post date:** [19 April 2022 08:34 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/6 "2022-04-19T08:34:40Z")

</div>

Now I figured out why

there's a checkbox in the write file node ("Create directory if it doesn't exist?")

if we just need to write file to H:/ drive, then we need to unselect this checkbox otherwise system will prompt out the error

for instance:  
h:/data.json =\> get error  
h:/newFolder/data.json =\> success to write file

it's quite weird but now the problem has been solved, I am able to create the file now :))

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.nodered.org/u/Kai)\
**Post date:** [19 April 2022 08:43 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/7 "2022-04-19T08:43:51Z")

</div>

actually the below syntax work for me:

- H:\\data..json
- H:\data.json
- H:/data.json

just remember to unselect the "create new directory" checkbox in the write file node  
 ![create_file](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/86e11d941c0df02726b0c1694120fd3383aa5eb3.png)

otherwise system will throw error 😅

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [19 April 2022 08:46 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/8 "2022-04-19T08:46:35Z")

</div>

Please look a bit more at the text from @Steve-Mcl ....

`On Windows path separators may need to be escaped for example \\Users\\myUser`

Please note the double `\\`.

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.nodered.org/u/Kai)\
**Post date:** [19 April 2022 08:48 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/9 "2022-04-19T08:48:02Z")

</div>

ok sure 👌

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 June 2022 08:48 UTC](https://discourse.nodered.org/t/unable-to-create-file-on-usb-drive/61467/10 "2022-06-18T08:48:24Z")

</div>

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