LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically associating .txt file to current project

Solved!
Go to solution

Dear all helpfull LabVIEW developers,

 

Is there anyway I can associate automatically/programmatically a file (.txt) in the project. The file is generated by a VI in the same project.

 

I know that I can associate an empty file to the project explorer and let the VI overwrite it and that will solve the issue, but I have now failed to remember this a couple of times so I guess it will happen again.

 

Looking very much forward to your valuable insights

 

BR

Mikkel 

0 Kudos
Message 1 of 7
(808 Views)
Solution
Accepted by topic author MikeBravo74

Hi,

 

set the project folder to "autopopulating" to include all files in your project folder...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(772 Views)

Hello, Mike.

 

     I just might have answered your question today in an earlier post on the Forum (see here).  I suggested creating a sub-folder called "Data" inside the Project Folder, adding this to the Project itself, and showing how the File I/O constant "Application Directory" points to this Folder.

 

     I suspect this may also solve your question.  In your Project, read (or write) your Text files into the folder "pointed to" by Application Directory.  As long as they "stay with the Project" (and you don't "move" the "Data" folder within the Project Folder), you'll know where they are!  The Bonus is if you build an Application (.exe) from within the Project, the Data Folder (and its contents!) will "automagically" transfer to the Built Application (which will include a Data folder).

 

Bob Schor

Message 3 of 7
(715 Views)

Dear Bob,

Thank you for taking your time to make a suggestion. It do not entirely solve my problem as I now have to remember to add the folder Data to the project. Before I had to add the text file to the project and overwrite that by the VI. The problem is that I have forgotten these details a couple of times which causes some double work. What I am looking for is a "hands-of" entirely embbeded in the VI - it may not be possible and I just need to add it to a analoque checklist (and remember to check it!!). I always try at my best to let a program ensure that I do not forget stuff, but it may have come to and end here:-)

BR

Mikkel

0 Kudos
Message 4 of 7
(697 Views)

Dear Gerd,

Thank you also for taking your time. As you can see in my answer to Bob below I am seeking an all-embedded-in-the-code if possible, but I acknowledge that your suggestion is pretty straightforward as well

BR

Mikkel

0 Kudos
Message 5 of 7
(628 Views)
Solution
Accepted by topic author MikeBravo74

You may be looking for something like this (not a snippet):

 

add_to_lvproj.png

 

This will programmatically add a file to your lvproj under the "my computer" target.  You could add additional logic to programmatically determine the paths to the text file(s) that you want added.

Message 6 of 7
(616 Views)

Hi Playerm1

As far as I read your suggested code this was exactly what I was aiming for. I'll integrate and give a follow up - thanx

 

I always immediately answer YES when my students asks: "can LabVIEW do ...." - even without hearing the ...., so I would not like to brake the chain by this post and fortunately LabVIEW can of course  add a .txt-file to the project!

0 Kudos
Message 7 of 7
(593 Views)