09-27-2012 06:02 AM
I am trying to create a time-stamped folder, and then within the folder, create a file called "Report.txt".
See below snippet.
The time-stamped part is correct - no argue about this, because a folder is really created, i.e ..\20120927185155
However in the time-stamped folder, it is empty. Apparently "Report.txt" wasn't created, for some reason.
Please help.
TIA!!
Solved! Go to Solution.
09-27-2012 06:11 AM - edited 09-27-2012 06:21 AM
You have a race condition between creating the folder and creating the file. There's nothing defining the execution order. Make sure the folder is created before trying to create the file. Also, use "build path" (just like you do for the directory) to create the file path instead of converting to a string and back.
09-27-2012 06:15 AM
Oh yes.. cos it is random. Sometimes the file is created, sometimes not. Most of the time it is not created.
I will try to use a sequence.
I can use a constant instead of "enum"?
09-27-2012 06:28 AM
Instead of a sequence you could also use data flow (using the path output or the error cluster of create folder). Can be problematic though if there is an error in the create folder function.
What "enum" are you talking about? I don't see an enum in your snippet.
09-27-2012 06:30 AM
The enum which is supposed to be used for the open/create/file..
09-27-2012 06:39 AM
Ah I see. Yes, that works. But I don't see why you would do that.
The constant value gets translated into the corresponding enum position, so as long as the enum does not change using an integer constant will work. I would recommend using an enum constant, this also makes the code easier to read.
09-27-2012 07:51 AM
Have you looked at the "Format Date/Time String" function?
09-27-2012 07:53 AM - edited 09-27-2012 07:53 AM
Omar beat me to it. Your whole business with the clusters and building of strings and be reduced down to just a Format Time String and a couple of Build Paths. Here's a much cleaner version of your VI.