LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to list the contents of folders contained in a packaged exe

I packaged an Application.exe on my D drive, which contains a folder 'Structrue',

and the output path when I run the program is: D:\builds\test\My Application\Application.exe\Structure.

Is there any way to list all the vi's contained in 'Structrue' folder?

0 Kudos
Message 1 of 13
(1,065 Views)

Hi hy,

 

have you tried the ListFolder function? (Which error did you encounter?)

 

What's the point in listing the contents of an executable? You should know which code is used to build the exe!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(1,042 Views)

I'm not even sure the exe explicitly stores a folder structure.

 

IIRC, VIs (.lvclass .ctl, etc.) do store their relative paths though.

 

So, you can try to get all VIs, classes, etc. by reference and use their path property to build a folder structure.

0 Kudos
Message 3 of 13
(1,037 Views)

The listfolder doesn't work after packaging, it should only list items in the actual path.

 

I don't want to give away the contents of the structures, so I didn't pack the folder directly into the application directory. But I want to be able to dynamically get all the structures inside the folder so that I can parse the data inside the PLC.

0 Kudos
Message 4 of 13
(996 Views)

I'll give it a try.

0 Kudos
Message 5 of 13
(994 Views)

If I understand your question, I do this all the time, both when developing and when running the Executable.  As you've noticed, by default, a standard Build creates a folder called "Data" at a known location in the path where you specify the Build.  You can use LabVIEW functions to find this folder -- do a Build Path with "Application Directory" (defined in File I/O, File Constants) as the Folder and "Data" as the File).  I also put a Data folder in my Project as a top-level folder in the Project, so when I'm testing my code during development, it will (also) find the Project's Data File in exactly the same location!

 

Files (and Folders) that you put in either the "Project" Data Folder (during Development) or "Execution" Data Folder (on your 😧 drive at the location you show in your Post) can be opened, listed, read, written, etc. as your application requires.

 

So going back to the "Question you asked" (as opposed to the "Question I chose to Answer", sorry about that), you should find your "Structure" folder by doing a Build Path with <Path from Application Directory File Constants> and "Structure", then doing whatever file I/O ("List Folder", for example) on the resulting Path.  You can also, of course, read, write, delete, etc. files and folders you find there.

 

Something else of note.  Suppose you want another Folder to show up on your Build, in addition to Data.  In the Build, you can request additional Folders.  Go to "Destinations" (third Category in Build) .  You may already find the Data directory created under the "Destination" called Support Directory.  I use this one as a "Write Mostly from the Program" folder.  I often add a "Config" Folder (which has things to read) by clicking the Plus sign at the bottom, calling it something meaningful (like "Config"), and creating a meaningrful Path (I make it the same as for "Data", but substitute "Config" for "Data").  If you want to test your "Config" code during Development, simply add a Config Folder at the top level of the Project File structure.

 

Bob Schor

0 Kudos
Message 6 of 13
(926 Views)

wiebe@CARYA wrote:

I'm not even sure the exe explicitly stores a folder structure.

Actually an exe is more or less a ZIP file with all the compiled VIs.inside in the file structure as defined in the project/build settings, plus some startup executable that locates the LabVIEW runtime and loads and initializes it. In old times it used to be an LLB but that did not support classes and libraries well with their members that often are using the same file name. 
Back then List Folder could browse.into an executable but the outcry was enormous about how this allowed anybody to steal the code in an executable (the thing one could “steal” were the names of the VIs and nothing more but paranoia can be an interesting state of mind). But NI listened and removed the ability to browse into exe files and did not add it back when they switched to the ZIP archive format. For a brief moment some unzippers could recognize the ZIP archive structure inside an exe but the internal format was changed enough that unzippers can’t unpack it anymore.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 13
(911 Views)

@rolfk wrote:

wiebe@CARYA wrote:

I'm not even sure the exe explicitly stores a folder structure.

Actually an exe is more or less a ZIP file with all the compiled VIs.inside in the file structure as defined in the project/build settings, plus some startup executable that locates the LabVIEW runtime and loads and initializes it. In old times it used to be an LLB but that did not support classes and libraries well with their members that often are using the same file name. 
Back then List Folder could browse.into an executable but the outcry was enormous about how this allowed anybody to steal the code in an executable (the thing one could “steal” were the names of the VIs and nothing more but paranoia can be an interesting state of mind). But NI listened and removed the ability to browse into exe files and did not add it back when they switched to the ZIP archive format. For a brief moment some unzippers could recognize the ZIP archive structure inside an exe but the internal format was changed enough that unzippers can’t unpack it anymore.


Getting all VIs from an exe is still very easy of course.

 

Main questing here is why OP wants to do this?

0 Kudos
Message 8 of 13
(870 Views)

wiebe@CARYA wrote:


Getting all VIs from an exe is still very easy of course.


How can a listing of the VIs or even just of the folders be gotten?

0 Kudos
Message 9 of 13
(286 Views)

wiebe@CARYA wrote:

So, you can try to get all VIs, classes, etc. by reference and use their path property to build a folder structure.


How to get references of unopened dynamically-called Always Included VIs?

0 Kudos
Message 10 of 13
(281 Views)