08-27-2012 01:30 AM
I am using a user-dialog to prompt user to enter a string.
Then I will convert this string to path, and then use this path to create a folder, and then copy some files into this newly created folder.
The problem is, if the folder already exist, it will replace it with a new empty folder - which is not what I want.
I want that, if the folder already exist, do not replace it. Just copy some files into the existing folder.
Anyone can help?
08-27-2012 01:44 AM - edited 08-27-2012 01:47 AM
Use Check if File or Folder Exists VI to determine if the folder already exists.If the folder doesn't exists then create it.
08-27-2012 01:48 AM
OK. So basically I have a folder C:\Machine#123
So everytime someone clicks a button and input a string, say Machine#456, a new directory C:\Machine#456 will be created, and also a time-stamped subdirectory will also be created. However if user key in Machine#123, and since this directory already existed, it will replace it with an empty new directory C:\Machine#123, which is a problem.
For example:
Existing directory:
C:\Machine#123\201208271200\
If user key "Machine#456", new directory will be created:
C:\Machine#456\201208271205\
But if user key "Machine#123", the existing directory will be wiped out and replaced by this:
C:\Machine#123\201208271210\
08-27-2012 01:58 AM
Can you show your code? What LV version and OS are you using?
When I use "Create Folder" on an existing folder it will not do anything and return error 10 (duplicate path) instead.
08-27-2012 01:59 AM
Hi Splee,
All you need to do is use the above function that i have mentioned to check if the folder exists.If the folder exists then bypass the folder creation and just do the other function like copying files.. etc.Are you able to find that function?
08-27-2012 02:21 AM
I am using Windows XP, LV2010
08-27-2012 02:48 AM
I still don't see the problem. Create folder just creates a new subfolder, but does not wipe any other subfolder.
For instance, if I have a folder "C:\Machine#123\201208271210" and use "Machine#123" again it will create a new subfolder "201208271220" but will leave the "...1210" folder there.
I'm not sure what the move function at the end of your code is supposed to do, but this should also not delete previous directories.
08-27-2012 03:17 AM
Hi
Some curious questions:
Why are you using the unbundle, bundle and again unbundle functions? you are finally getting the same time and date details in the first cluster as in the second! you could have directly taken the data from the time and date cluster directly!
You have an appended path indicator overlapping the appeneded path control. What is the path written into the appended path control?
Are you sure the folders are deleted? Are they being moved to the path in the 'appended path' control?
08-27-2012 03:38 AM - edited 08-27-2012 03:40 AM
Hi Splee and Freelance,
to take the unbundle/bundle dance even further:
- why do you convert the timestamp to DBL before converting to time cluster?
- why do you use all that functions at all, including a loop to convert the numbers into string? There's a function "Format Date/Time string" that will do all those functionality with just a proper format string:
You should be working with real path controls/constants instead of covnerting to/from string all the time...
08-27-2012 05:00 AM
Oh Yes!
It would have been far easier to format the timestamp directly, than all that manipulation.