From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a directory

Hi all ,
I'd like to create a .vi that DELETE A DIRECTORY that I select .
I try to use the advanced file functions "delete" but I succeed to delete
just single files .
Thanks .
0 Kudos
Message 1 of 3
(2,629 Views)
It only deletes directories that are empty.

Just use "List diretory" first, use the "file names" output array and delete them in a FOR loop, then delete the folder.
0 Kudos
Message 2 of 3
(2,629 Views)
Pedrus wrote:

> Hi all ,
> I'd like to create a .vi that DELETE A DIRECTORY that I select .
> I try to use the advanced file functions "delete" but I succeed to delete
> just single files .

There is a gotcha. You have to provide the path to the directory and
make sure that directoy is empty before it will work. Basically this
means a recursive algorithme which isn't to difficult to implement in
LabVIEW if you once know how to do it.
However there is no need to invent the wheel again as on
http://www.openg.org there is the OpenG Toolkit which has in its File
library just that Delete Recursive function.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(2,629 Views)