How can I create txt file if it does not exist?

How can I create txt file if it does not exist?

manuel_s4
Not applicable
74 Views
2 Replies
Message 1 of 3

How can I create txt file if it does not exist?

manuel_s4
Not applicable

[ FlexSim 19.1.0 ]

I want to export some data to a .txt file but first I need to check if it exists with command fileexists. If it doesn't, I want to create the .txt file automatically and then fill it out with the data.

Thanks.

Manuel.

0 Likes
Accepted solutions (1)
75 Views
2 Replies
Replies (2)
Message 2 of 3

JordanLJohnson
Autodesk
Autodesk
Accepted solution

If you use the command fileopen(fileName, "w"), and the path is valid, then the file will be created, even if it doesn't exist.

.


Jordan Johnson
Principal Software Engineer
>

Message 3 of 3

manuel_s4
Not applicable

Thanks @jordan.johnson, it worked perfectly.

0 Likes