取消
显示结果 
搜索替代 
您的意思是: 

absolute path

已解决!
转到解答
Hi All,
 
I need to save some data in an xml file. First, I need to specify the path where the file will be stored. I tried using a relative path without much success (see error at the end of the file) and I've been unable to find out how to get the absolute path where the vi is located. I want to save the xml file in the current folder where the vi is saved. I want to be able to run the vi even if I move the vi to a different path, without having to change the path string on my block diagram. I tried using Build Path component or String To Path, but they don't seem to do what I want. So, I am looking for a way of getting a string with the current folder path of the vi, which then I can use as an absolute path.
 
Using a Built Path component, I tried using a relative path (like filename.xml for the path string), but I get a strange error with the Write To XML component:
 
Error 1 occured at open file.
Possible reason(s):
LabVIEW:  An input parameter is invalid.
---
NI-488:  Command requires GPIB Controller to be Controller in Charge.
 
When I used a string and a String To Path component, I got this error:
 
Possible reason(s):
LabVIEW:  The path is empty or relative. You must use an absolute path. (and yet, in the help, they advise to use relative paths).
 
Regards,
Nick

Message Edited by Nick_F on 08-22-2006 12:03 AM

1 条消息(共 15 条)
19,686 次查看
I found out myself. I had to add a Default Directory constant to the block diagram, and use it in conjunction with the build path.
0 项奖励
2 条消息(共 15 条)
19,680 次查看

Hi,

 

I was wondering where you attached the default directory to? Base path?

 

Lawrence

0 项奖励
3 条消息(共 15 条)
19,239 次查看
You can generate an absolute path by using Current VI's Path, then stripping it a level and building it back to where the file is you're trying to get at.
Jeff | LabVIEW Software Engineer
0 项奖励
4 条消息(共 15 条)
19,214 次查看

How exactly do you do this? I am getting the same error message when trying to open a file in my default case, writing to it in the next two cases, and then closing it in the last case. (And I'm having problems closing my AWG, but that's fine).

0 项奖励
5 条消息(共 15 条)
18,439 次查看

If you place the attached as a sub-vi, it will provide the folder that the calling vi is stored in. This will work in both the development environment and in an exe.

Is that what you need?

6 条消息(共 15 条)
18,429 次查看

Hehe 🙂 It didn't quite solve my problem, but it solved another problem I've had! I'm not sure how I should have used it to extract the absolute file path and use it further.

 

I solved the problem with my current structure by using local variables instead of global. I hope that wasn't a bad fix? 

0 项奖励
7 条消息(共 15 条)
18,415 次查看

Try putting changing the case statement so that the case for 'Run Time System' only has one strip path, and the default case just wires the path straight through without changing it. This should give you the path of the file rather than the folder it is in.

 

Apologies if this still isn't what you're after... I'm guessing a bit as I can't open your code as I'm on an old version of LabVIEW (8.5)

 

Ian

0 项奖励
8 条消息(共 15 条)
18,411 次查看

Here's the simplest way to return the folder directory path of the current VI; just open the snippet up in LabVIEW to view the code.

 

AbsolutePath.png


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 项奖励
9 条消息(共 15 条)
18,400 次查看

This would seem relevant at this point, in case anyone gets any surprises:

 

Why Does My Executable Not Work When Using the Current VI's Path Constant?

10 条消息(共 15 条)
18,387 次查看