# File path exist, but getting error "The system cannot find the path specified"

**URL:** <https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562>\
**Category:** Ignition\
**Created:** [January 13, 2023, 1:52am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562 "2023-01-13T01:52:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yin.cheng](https://avatars.discourse-cdn.com/v4/letter/y/85f322/32.png) [@yin.cheng](https://forum.inductiveautomation.com/u/yin.cheng)\
**Post date:** [January 13, 2023, 1:52am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/1 "2023-01-13T01:52:23Z")

</div>

Hi all, i have a scheduled Gateway Event Script as below:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f1b9553fc6738316f6d6a223ed89c194b17d90e9.png)

```auto
def dataExport():
	#query data
	data = system.db.runNamedQuery(something)
	
	#export to csv
	csvData = system.dataset.toCSV(data)
	
	#check if folder exist
	folderPath = "C:\\test"
	if system.file.fileExists(folderPath):
		#export file
		filePath = folderPath + "\\some_exported_file.csv"
		system.file.writeFile(filePath, csvData)		
	else:
		dummy = 1

```

Now, the file is able to export, but at the same time i am getting error:

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

```auto
java.io.FileNotFoundException: C:\Windows\Temp\jetty-0_0_0_0-8088-main-_-any-9867179302079148073\WicketFilter-filestore\1197\5854\node0sbs7tgpi2g3xshtcucvixzjr0\data (The system cannot find the path specified)

at java.base/java.io.RandomAccessFile.open0(Native Method)

at java.base/java.io.RandomAccessFile.open(Unknown Source)

at java.base/java.io.RandomAccessFile.(Unknown Source)

at java.base/java.io.RandomAccessFile.(Unknown Source)

at org.apache.wicket.pageStore.DiskDataStore$SessionEntry.getFileChannel(DiskDataStore.java:432)

at org.apache.wicket.pageStore.DiskDataStore$SessionEntry.savePage(DiskDataStore.java:350)

at org.apache.wicket.pageStore.DiskDataStore.storeData(DiskDataStore.java:188)

at org.apache.wicket.pageStore.AsynchronousDataStore$PageSavingRunnable.run(AsynchronousDataStore.java:355)

at java.base/java.lang.Thread.run(Unknown Source)

```

Am i missing a step somewhere?  
Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 13, 2023, 9:06am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/2 "2023-01-13T09:06:28Z")

</div>

I presume you're looking for this folder on your gateway and not locally?

---

<div class="post-metadata">

**Author:** ![yin.cheng](https://avatars.discourse-cdn.com/v4/letter/y/85f322/32.png) [@yin.cheng](https://forum.inductiveautomation.com/u/yin.cheng)\
**Post date:** [January 13, 2023, 9:20am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/3 "2023-01-13T09:20:32Z")

</div>

Yes.  
The files managed to saved in the mentioned folder as well.

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [February 1, 2023, 9:34am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/4 "2023-02-01T09:34:41Z")

</div>

@nminchin How can you open a file on the server where the gateway is installed?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 1, 2023, 9:52am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/5 "2023-02-01T09:52:51Z")

</div>

From where? Perspective? Vision? Gateway script?

Perspective and gateway/tag script are all run in the gateway scope, so you can just use the normal python methods with the `os` library

```auto
for (dirPath, dirs, files) in os.walk(filePath):
   print files
   break

```

from memory will walk recursively through a folder. Break it after the first run to make it not recursive

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 1, 2023, 10:28am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/6 "2023-02-01T10:28:18Z")

</div>

> [@nminchin](#):
>
> Break it after the first run to make it not recursive

Or just don't put it in a loop.

```python
root, dirs, files = next(os.walk('path'))

```

alternatively, you could use `os.listdir`, which returns everything that's at the specified path.  
You can filter for files only with `isfile()`, which you can import from `os.path`

```python
from os import listdir
from os.path import isfile, join

files = [f for f in os.listdir(path) if isfile(join(path, f))]

```

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [February 1, 2023, 10:34am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/7 "2023-02-01T10:34:41Z")

</div>

from vision, using the pdf reader

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 1, 2023, 10:38am UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/8 "2023-02-01T10:38:03Z")

</div>

From Vision it's trickier. However the easiest method is to create a fileshare and access the files using the UNC path to it

---

<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:** [February 1, 2023, 12:56pm UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/9 "2023-02-01T12:56:41Z")

</div>

You can use `system.util.sendRequest()` to message a handler in the gateway. Such a handler can open a file for you and return the bytes. Then assign those bytes to the PDF Viewer.

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [February 7, 2023, 3:13pm UTC](https://forum.inductiveautomation.com/t/file-path-exist-but-getting-error-the-system-cannot-find-the-path-specified/68562/10 "2023-02-07T15:13:10Z")

</div>

I have solved it using this manual [Storing Files in a Database - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Storing+Files+in+a+Database)
