LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

finding the directory name?

Hi I need to find the directory name that contains my project file.

I have read posts such as http://forums.ni.com/ni/board/message?board.id=180&message.id=3847&requireLogin=False.

However GetProjectDir does not return the correct path. It seems to return the directory containing the binary which
in my case will not be the project directory.

Is there no predefined macro reflecting the project build dir / name ?

GetDir also returns the binary directory.

Thanks for the help.
0 Kudos
Message 1 of 5
(3,485 Views)
Have you tried using GetProjectDir ()? It is located in the Utility library and according to the online documentation seems to satisfy your needs:

"Obtains the directory containing the currently loaded project file.

This function is useful when a project and its related files are distributed to multiple users who may place them in a different directory on each machine, If your program needs to access a file that is in the same directory as the project, you can use GetProjectDir and MakePathname to construct the full pathname.

In a standalone executable, the function obtains the directory
containing the executable file."


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(3,476 Views)
Sorry, I didn't read carefully your question...


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 5
(3,475 Views)
Why does your program need to know the directory in which it was built?
In general, I think the two directories should be completely independent. You can build it wherever you want to and the user can install it into a different directory.
If you need some support files, e.g. ini files, icons, graphics, DLL's, etc., you can include those files in a distribution kit so they will get installed along with the executable when the user runs setup.exe.
0 Kudos
Message 4 of 5
(3,466 Views)
This is from the function panel help for GetProjectDir():

"Gets the name of the directory that contains the currently loaded project file.

You can use GetProjectDir when you distribute a project and its related files to multiple users who might place the files in a different directory on each computer. If your program needs to access a file that is in the same directory as the project, you can use GetProjectDir and MakePathname to construct the full pathname.

In a stand-alone executable, the function obtains the directory containing the executable file."


The last sentence there is key. Since all CVI programs run as stand-alone executables since about CVI 5.0 (IIRC), this function is always going to return the directory that the executable file lives in. Meaning that the only time it will return the actual project directory is if it is running from the project directory.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
Message 5 of 5
(3,451 Views)