LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to file path

I am looking for a function in LabVIEW and it seems to be hiding from me.
I have data write to a file in my VI.
 
There are 3 strings:
1) constant - file path preceding the name of the file
2) control - the user can type in whatever name they want
3) constant - ".txt"
 
The 3 strings are then concatenated.
Can I turn that concatenated string into a filepath?
It would be really cool if there was a "string to filepath" function, but I cant find it.
Cory K
0 Kudos
Message 1 of 10
(17,030 Views)
OK, nevermind
Of course right after I post my question, I found the function moments later.
Thanks anyway
Cory K
Message 2 of 10
(17,029 Views)
Glad you found your own solution.  There are many ways of implementing your solution.  However, here are a couple of simple and straight-forward solutions that may be useful for someone reading this thread.
 
R
 


Message Edited by JoeLabView on 07-30-2008 08:49 PM
Message 3 of 10
(17,012 Views)


JoeLabView wrote:

Actually, only the lower version is acceptable here.
 
The upper version will fail if the path is anything but "c:\" (or similar), because you'll not get the "\" delimiter. (e.g. if path is "c:\dir1", you'll end up with c:\dir1filename.txt instead of  c:\dir1\filename.txt. It is also hard to justify the use of three operations for something that can be done in a single step.
 
Also, remember that "string to path" and "path to string" can often break platform independence.
Message 4 of 10
(16,996 Views)

Hi-

This thread is still relevant 5 years later...

So, if I do want to have my base path as C:\dir1\ instaed of C:\ what shall I do?

Thanks

DaniDin

DaniDin
0 Kudos
Message 5 of 10
(16,045 Views)

This

 

EDIT:  Just noticed I used base1 instead of dir1, but you should get the point.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(16,035 Views)

Crossrulz-

Your suggestion to specify a subdirectory "base1" in the base path argument as: C:\base1 does not work. See the 2008 entry by altenbach. When doing that, the intended base1 subdirectory ends up being the prefix of the filename.

So, instead of obtaining: "C:\base1\filename.txt", I end up with: "C:\base1filename.txt".

DaniDin
0 Kudos
Message 7 of 10
(16,029 Views)

The goal can be accomplished by simply concatenating the sub folder "base1\" as a constant before the filename.

So the base path is still "C:\", then in the second argument of the "Build Path" function, concatenate "Base1\ with "Filename", and with ".txt"

DaniDin
0 Kudos
Message 8 of 10
(16,022 Views)

@DaniDin wrote:

Crossrulz-

Your suggestion to specify a subdirectory "base1" in the base path argument as: C:\base1 does not work. See the 2008 entry by altenbach. When doing that, the intended base1 subdirectory ends up being the prefix of the filename.

So, instead of obtaining: "C:\base1\filename.txt", I end up with: "C:\base1filename.txt".


Did you run the crossrulz post?  It works as expected returning c:\base1\filename.txt  The comment altenbach said was that you may run into issues if you just use concatenate string instead of build path.

0 Kudos
Message 9 of 10
(16,021 Views)

@DaniDin wrote:

The goal can be accomplished by simply concatenating the sub folder "base1\" as a constant before the filename.

So the base path is still "C:\", then in the second argument of the "Build Path" function, concatenate "Base1\ with "Filename", and with ".txt"


You are making life too difficult.  Trust me.  The code I gave you will do exactly what you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 10
(16,016 Views)