Ir al contenido principal

Release current directory

This is not mine, it's a tip I found years ago in a LabVIEW forum and still works like a charm (thanks to the genious that got it!).

When the user selects a file to work with (signal data you want to analyze, for example) your LabVIEW application "grabs" its path, so you can't delete it or its directory, or unmount the unit if you're using an external drive, even if you are not reading that file anymore and you clear any path controls. But we can use Kernel32.dll method SetCurrentDirectoryA to release it (obviously, this only works in Windows systems).

No downloadable code today, it's better if you link the call library function node by yourself, so you're sure it finds the dll. You can find more info about this method here: SetCurrentDirectory function at MSDN.


Entradas populares de este blog

CIDR to netmask

To begin with, something basic but useful, a LabVIEW VI for converting CIDR suffix to a standard IP mask. As you know, in CIDR format the number after the IP indicates the bits that address uses. If you need to convert to a traditional subnet mask, this VI comes handy.So, a CIDR of 24 will return a mask, 28 is, etc. Pretty simple, but a lot of applications demand netmasks in this format.Download (VI for LabVIEW 2016)LabVIEW still only supports IPv4, so I haven't delved into the complexities of IPv6 (we'd need a U128 data type for that).

Variant to XML

Converting to XML format is a good way of exporting data in a standard, human-readable way. I have used it to pass and receive data from other languages, for example, or if you need to dump data to a log file.As you may know, LabVIEW includes its own functions for converting to and from XML, called Flatten To XML and Unflatten From XML. Unfortunately, it's a raw conversion that just gives a node with the data type and two child nodes, name and value. So, to find a field you must recover first all the name nodes, locate the one you need and then find its value sibling. Too crude for a lot of scenarios:So I developed my own library to do this conversion in a more convenient way. Check the differences in the next image:As you can see the field names are now used as tag names, resulting in a shorter and cleaner XML text. The reverse conversion (from XML to LabVIEW data) is shown in the bottom of the image, and works the same.In the block diagram, these functions are used directly, jus…


Welcome to Solar Code, a personal blog by Aitor Solar (yeah, the blog's name is just a bad pun on my surname). Here I will post my programming tips and solutions, mainly for LabVIEW (though some JavaScript is foreseen). All the code and tips in this blog come with no warranty, you use it at your own risk. Any questions regarding it should be directed to Aitor Solar at