LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Create Folder" - but it replaces existing folder!

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?

0 Kudos
Message 1 of 16
(2,981 Views)

Use Check if File or Folder Exists VI to determine if the folder already exists.If the folder doesn't exists then create it.

Message 2 of 16
(2,976 Views)

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\

0 Kudos
Message 3 of 16
(2,972 Views)

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.

 

 

Message 4 of 16
(2,967 Views)

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?

 

       

Message 5 of 16
(2,966 Views)

create_Subfolder.png

 

I am using Windows XP, LV2010

0 Kudos
Message 6 of 16
(2,955 Views)

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.


Message 7 of 16
(2,945 Views)

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?

 

 

Regards
Freelance_LV
TestAutomation Consultant
Message 8 of 16
(2,939 Views)

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:

check.png

 

You should be working with real path controls/constants instead of covnerting to/from string all the time...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 16
(2,934 Views)

Oh Yes!

 

It would have been far easier to format the timestamp directly, than all that manipulation.

 

Regards
Freelance_LV
TestAutomation Consultant
Message 10 of 16
(2,922 Views)