# Access a network drive

**URL:** <https://forum.inductiveautomation.com/t/access-a-network-drive/54410>\
**Category:** Ignition\
**Created:** [December 22, 2021, 9:00pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410 "2021-12-22T21:00:51Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 6, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/22 "2022-01-06T14:49:33Z")

</div>

Ignition runs as a service, so it can’t access mapped drives on the host computer. Instead, you map it inside Ignition to allow for access. You don’t need `D:` to be mapped on the host, you just do the config file addition then stop and start Ignition. It should then be mapped and accessible from Ignition as `D:\sampleImage.png`

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [January 6, 2022, 2:54pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/23 "2022-01-06T14:54:23Z")

</div>

So this is what I want to do:

There is a folder in my network drive with some pictures in it. I would like to be able to access that folder and get the picture names and put it on a list

I did not configure anything in my D drive and I did not create any folders on my D drive.

How is this going to be possible?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 6, 2022, 2:58pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/24 "2022-01-06T14:58:45Z")

</div>

```auto
wrapper.share.1.location="\\fileserver4\Automation\"
wrapper.share.1.target=I:
wrapper.share.1.type=DISK

```

```auto
    import os
	input_path = "I:\"
	fileList = os.listdir(input_path)
	self.getSibling("TextArea").props.text=fileList

```

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [January 6, 2022, 3:25pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/25 "2022-01-06T15:25:17Z")

</div>

I get the same error:

```auto
org.python.core.PyException
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

	caused by IllegalArgumentException: Cannot create PyString with non-byte value

```

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 6, 2022, 3:27pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/26 "2022-01-06T15:27:58Z")

</div>

What line does it say the error is coming from?

Go to the script console and run this:

```auto
    import os
	input_path = "I:\"
	fileList = os.listdir(input_path)
    print fileList

```

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [January 6, 2022, 3:36pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/27 "2022-01-06T15:36:57Z")

</div>

it says 'input\_path" is not defined.  
should this be  
`input_path = "I:\"`  
or

`input_path = "I:\full path"`

?

I have tried with both

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 6, 2022, 3:46pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/28 "2022-01-06T15:46:12Z")

</div>

Sorry, forgot, need two backslashes after drive letter

```auto
"I:\\"

```

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [January 6, 2022, 3:55pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/29 "2022-01-06T15:55:39Z")

</div>

This gives me the content of the I folder, not that specific folder I want and when I write the full path one time I get this error:

```auto
Traceback (most recent call last):
  File "<input>", line 2, in <module>
TypeError: coercing to Unicode: need string, list type found

```

and another time I get the list of what has been in “I” folder!!! It is very strange!

So I get two different results for the same script and none of them is what I am expecting to get.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 6, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/30 "2022-01-06T16:02:28Z")

</div>

Don’t just use `I:\\` This only represents `\\fileserver4\Automation\` from what I can tell. If you need to drill down into another folder in `I:\\` then you need to include that in the path.

```auto
I:\\fullPath

```

Show me your full path assigned to `input_path`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 6, 2022, 4:06pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/31 "2022-01-06T16:06:58Z")

</div>

In python strings, as in most programming languages, backslashes are special. To use them in your paths, you need to double all your backslashes.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [January 6, 2022, 5:47pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/32 "2022-01-06T17:47:10Z")

</div>

Thank you!!! I was able to get the file names in the console, now I am using the exact same script on my button event handler which uses double backslash but I get an error. It is working in the console but not on the event handler

`OSError: [Errno 20] Not a directory`

This is my code and the folder that I was looking for was in the Y folder instead of I, I changed everything based on that.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/ba10c7f3c9906c9b2f5361156c82685f07d3eef6.png)

```auto
import os
	input_path ="Y:\\MES Ignition\\Controls\\Design\\sample Image Folder\\Images\\20\\Pass_Barcode\\"
	fileList = os.listdir(input_path)
	self.getSibling("TextArea").props.text=fileList

```

And in my wrapper I am using:

```auto
wrapper.share.1.location="\\fileserver4\Automation\"
wrapper.share.1.target=Y:
wrapper.share.1.type=DISK

wrapper.ntservice.account=user #my own username
wrapper.ntservice.password=pass #my own pass
wrapper.share.1.account=domain\user #my own domain\user
wrapper.share.1.password=pass #my own pass

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 6, 2022, 6:40pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/33 "2022-01-06T18:40:34Z")

</div>

It maybe a scope issue. I think clients will use the file system of the client computer and not the gateway computer so it is looking for a `Y` drive on the client not the gateway. You would need to call it from a gateway script I believe.

---

<div class="post-metadata">

**Author:** ![Eve\_Dang](https://avatars.discourse-cdn.com/v4/letter/e/50afbb/32.png) [@Eve\_Dang](https://forum.inductiveautomation.com/u/Eve_Dang)\
**Post date:** [January 18, 2023, 9:58pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/34 "2023-01-18T21:58:09Z")

</div>

Hi, I also have the same problem with network drive. Even after changing the config file and checking using the script console, my Gateway script still can not access network drive. Could you fix your problem after that? Many thanks.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 18, 2023, 10:31pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/35 "2023-01-18T22:31:53Z")

</div>

> [@Eve\_Dang](#):
>
> checking using the script console

That isn't a valid check. The script console runs in Designer scope, not gateway scope. Opening a desktop session on the gateway to run the designer is not the same environment as a service.

Did you restart the gateway after changing the config file? And then check in your wrapper log to look for errors mapping the drive? (The wrapper log is a text file--it has information that does not show up in the gateway's logs via the web interface.)

---

<div class="post-metadata">

**Author:** ![Eve\_Dang](https://avatars.discourse-cdn.com/v4/letter/e/50afbb/32.png) [@Eve\_Dang](https://forum.inductiveautomation.com/u/Eve_Dang)\
**Post date:** [January 24, 2023, 5:07pm UTC](https://forum.inductiveautomation.com/t/access-a-network-drive/54410/36 "2023-01-24T17:07:52Z")

</div>

Hi Phil, thank you for your reply! I added the network drive and account credentials. However after checking the wrapper log file, somehow my correct input password is cut short during the stop and start process. As a result, the error is wrong network password. Do you know why? Thanks in advance.

[Previous page](https://forum.inductiveautomation.com/t/access-a-network-drive/54410.md?page=1)
