LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I have two '\\' in my appended path?

I have a vi that has worked well for years.  I took the basics for saving my data and made it part of a new vi.  It involves taking the base path, 'C:\' and taking the motor number (1001), and appending to it the file name for the data to save, 'finalvibes.dat'.  The expected appended path should be 'C:\FanVibes\1001\finalvibes.dat', but what I am getting is 'C:\\FanVibes\1001\finalvibes.dat'.  How come?

 

0 Kudos
Message 1 of 9
(2,793 Views)
Well, since you're not showing us how you're appending the path, we can't really answer without simply guessing. Are you using the Build Path functions(right way), or are you using strings (wrong way).
0 Kudos
Message 2 of 9
(2,790 Views)

Appending a path adds a \.  Pass it C: instead of C:\ and you will get a single c:\

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 9
(2,783 Views)

I tried that, but then again, maybe something else was wrong.  I believe when I tried to take the '\' out of the path, it automatically put it back in, but I could be wrong.

Thanks!

0 Kudos
Message 4 of 9
(2,778 Views)

Here is the screen of my save data portion.  I was correct.  For some reason, when I delete the '\', the software puts in back in.  If I erase the '\' and the semicolon, obviously the path is not valid.

Thanks in advance. 

By the way, the FanVibes folder is a valid folder on my C drive.  I am appending the date, the machine number (1001) and the type of data, finalvibes is spectra, time is time waveforms, and overalls are rms overall values.

 

0 Kudos
Message 5 of 9
(2,760 Views)

It appears you have "C:\(space)" in the constant.  At least this is what the probe at C:\ \FinalVibe.... is telling me.

Are you saying that when you delete the \ from C:\ it puts it back in?

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 9
(2,750 Views)
That is affirmative.  I know this structure works since I have used it before.
0 Kudos
Message 7 of 9
(2,747 Views)
If you could attach a very simple VI that demonstrates the problem (i.e. remove all the extra stuff around the path construction code and just send us that) we can probably diagnose the problem easily.  From your screenshot, I see that you are using strings and concatenation to build up paths, which is generally discouraged.  You really should be using path constants and Build Path functions instead.  This approach takes care of inserting path separators for you...no room for error there.
Message 8 of 9
(2,738 Views)

elset191 wrote:

It appears you have "C:\(space)" in the constant.  At least this is what the probe at C:\ \FinalVibe.... is telling me.

Are you saying that when you delete the \ from C:\ it puts it back in?


It's supposed to since it's a path constant, and "C:" is not, technically, a valid path.

 

The reason the extra "\" is there is indeed because there is a space at the end of the constant.

 

As I noted before, you should be using Build Path for all path creation. In your code you are using both. 

Message 9 of 9
(2,731 Views)