# System.file.writeFile issue creating new file

**URL:** <https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [February 24, 2022, 11:07pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539 "2022-02-24T23:07:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [February 24, 2022, 11:07pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539/1 "2022-02-24T23:07:58Z")

</div>

Hi  
I am currently using Ignition 8.1.14 and windows server 2019.  
I have created button function which create XML File and update it if it is same file.  
Is there different function to create a new file in same folder.

When i try to create a new file using System. File. Write File function i am getting error as specified below.

IOError: [Errno 2] File not found - D:\MGILL\WM\_25-Feb-2022 11:46:11.xml (The filename, directory name, or volume label syntax is incorrect)

Copy of sample code which is as follow:

# Write the xml to a file.

fileName = ('D:/MGILL/WM\_'+ DateTime + '.xml')  
if system.file.fileExists(fileName):  
system.file.writeFile(fileName, xmlOut)  
else:  
system.gui.messageBox("No, it doesn't exist")  
file = ('D:/MGILL/WM\_'+ DateTime + '.xml' )  
if file:  
system.file.writeFile(file, xmlOut)

Any suggestions?

---

<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 25, 2022, 1:36am UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539/2 "2022-02-25T01:36:47Z")

</div>

Is there a colon in your datetime string? Those aren’t legal in Windows filenames.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 25, 2022, 3:51am UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539/3 "2022-02-25T03:51:27Z")

</div>

As @pturmel said

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

> [@mandeep\_gill](#):
>
> D:\MGILL\WM\_25-Feb-2022 11:46:11.xml

That is the problem `:`

---

<div class="post-metadata">

**Author:** ![mandeep\_gill](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mandeep\_gill](https://forum.inductiveautomation.com/u/mandeep_gill)\
**Post date:** [February 27, 2022, 5:37pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539/4 "2022-02-27T17:37:42Z")

</div>

Thank Pturmel and Jespinmartin1. Yes it was " :" in the date and time format. once i corrected it. It is working fine now.  
Thanks Guys you are Dam good…

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 27, 2022, 6:01pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-issue-creating-new-file/56539/5 "2022-02-27T18:01:47Z")

</div>

Tip: use the `</>` code formatting button to preserve indents and apply syntax highlighting. Can you fix your original post using the edit button (pencil icon)? Thanks.
