Good morning, I'm writing in a specific folder some txt files as log. Before start to write any file I want to delete the folder content or at least delete some files in it, but I don't find the right command to do this. Can you help me? Thanks
Good morning, I'm writing in a specific folder some txt files as log. Before start to write any file I want to delete the folder content or at least delete some files in it, but I don't find the right command to do this. Can you help me? Thanks
Not sure if this is what your looking for or not. It deals with only single files (at a time). Would something like this work for you?
From the User Manual:
fileopen (str filename [, str opentype])
Thanks for your answer but it is not exactly what I need. I know how to create and write files, but my situation is this.
I have a directory, ex. C:\temp\logfile, where I write several files similar to these event1.txt, event2.txt, event3.txt, ecc. While my model is running I catch some events and for each fired event I write a specific file with a suffix (progressive counter or other) with some specific information. When I reset the model I would delete all files in the directory in order to start from zero with my data with a empty situation. I read some old posts of about 2 years ago where this is not possible using Flexsim instructions, but I hope you should find other way to do the same thing. Thanks for any suggestion.
string directory = "C:\\temp\\logfile\\"; treenode temp = model().first.subnodes.assert("temp"); temp.subnodes.clear(); getfilesindirectory(directory, "txt", temp); for (int r = 1; r <= temp.subnodes.length; r++) { string fileName = temp.subnodes[r].value; applicationcommand("deletefile", directory + fileName); }
Note that deleting files is not immediate. When you programmatically delete a file in Windows, it marks it for deletion and then actually deletes it later.
So if you query whether the file is still there on the line immediately after "deletefile," then the file will probably still exist. You need to separate your file deletion from your querying or creation of those files by some amount of real time.
Thanks Phil, it is exactly what I need. I updated my model and it works as I expected.
14 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved