rights 发表于 2004-11-18 00:00:52

摘自NI的一篇极好的文章!(打包后程序找不到辅助文件的解决方法)

<P>Why Can't My Executable Load My Included File When I Use Relative Path Encoding?</P>Primary Software: LabVIEW Development Systems
Primary Software Version: 6.1
Primary Software Fixed Version: N/A
Secondary Software:


Problem: I have created an application in LabVIEW that either creates or reads from an external file. I am using relative path encoding by using the Current VI's Path function in the Functions Palette &raquo; File I/O subpalette. My program runs in the development environment and is able to successfully perform file I/O. However, when I build my application into an executable using Application Builder, I receive an error indicating that either the file cannot be found, or the path is invalid.

Solution: Notice that when you use the Current VI's Path function in the development environment, it will return to you the path in which the VI is located as well as the name of the VI. Often, the Strip Path function is then used to remove this portion of the path, and then the path is used elsewhere in the program. When the program is now built into an executable, the name of the executable now becomes part of the path, in addition to the VI's name. For example, if a VI named "Application.vi" is saved in C:\Program Files\Application, the Current VI's Path function would return C:\Program Files\Application\Application.vi when run in the development environment. Now, if the VI is built into an executable with a name of "App.exe" and saved in the same directory location, the Current VI's Path function will return C:\Program Files\Application\App.exe\Application.vi. In this case, you will need to use the Strip Path function twice to strip both "Application.vi" and "App.exe" from the path to retrieve the directory in which the executable is located.

cpubbs 发表于 2004-11-18 00:06:14

这是在做一些数据库和一些自己另外加的非VI文件时常遇到的一个问题,在没有打包前的路径和打包后的路径不相同,所以要打包前要多加一个strip path才可以的,否则它找不到!这篇文章解释的就是这个问题!

飞雨天 发表于 2007-3-26 15:14:54

回复 #1 rights 的帖子

嘿, 不错的文章哈~~
不过这个是不是ni的一个bug呢?

wdyjz 发表于 2007-3-26 15:55:11

lv专门提供有属性节点进行判断是何种类型的状态,比如:编辑模式\可执行程序模式\错误模式\嵌入式运行系统模式,分开执行的.因此有这种原因.
可以采用 VI属性进行分离和判断.

wdyjz 发表于 2007-3-26 18:16:25

http://www.cpubbs.com/blog/?1288/action_viewspace_itemid_336.html
整理\参考,提供本人做的程序.

cpubbs 发表于 2007-3-26 18:43:40

王兄做的那个东东很好用!以后做程序的时候直接调用,非常方便!就不会有这种问题出现了,让程序在编辑和EXE状态都一样不用修改程序!

飞雨天 发表于 2007-3-26 18:50:43

嘿~~~~学习了!:lol
页: [1]
查看完整版本: 摘自NI的一篇极好的文章!(打包后程序找不到辅助文件的解决方法)