LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if a path is valid

Solved!
Go to solution

I have a need to check if a path entered by the user is valid.

 

That is to say that I want to be able to return an error if the path is left blank, doesn't point to the correct file type (.csv in this case) or points to an invalid location (i.e. a user typo).

 

The first and second are straightforward (using 'Empty string/path' and a simple string comparison, respectively), but I don't know how to implement the third.  I have tried the 'Not a number/path/refnum' block, but to no avail.

 

Any suggestions gratefully received.

 

Dan

Dan
CLD
0 Kudos
Message 1 of 10
(15,316 Views)

Hi Dan,

what is the third part?

Maybe the attached picture helps.

 

 

CheckPath.png

 

Mike

Message 2 of 10
(15,312 Views)

Hi Mike,

 

Thanks for the reply.

 

Your solution is essentially exactly the same as what I tried initially.

 

However, I'm not able to get the 'Not a number/path/refnum' block to produce a TRUE output.

 

Under what circumstances should this block give a TRUE output?

 

Dan

Dan
CLD
0 Kudos
Message 3 of 10
(15,307 Views)

Hi Dan,

you'll get a true if you connect the "Not a Path" constant to it. You can use it to check if the path changes after you have initialized it with "Not a Path".

 

Mike

0 Kudos
Message 4 of 10
(15,303 Views)

OK then, back to my specific problem...

 

I want to be able to check that a user-entered path actually points to a file that exists.

 

For example:

 

Say the geniune file is C:\Documents and Settings\test_file.csv.

 

However suppose the user enters something like C:\Documents and Sattings\test_file.csv or C:\Documents and Settings\toast_file.csv.

 

I want my VI to be able to pick up the error, and flag it up, before Labview tries and fails to open the file.

Dan
CLD
0 Kudos
Message 5 of 10
(15,296 Views)
Solution
Accepted by DanB1983

Hi Dan,

which LabVIEW version do you use? In  LabVIEW 8.5 an later, there is a function "Check if File or Folder exists". If you use an earlier version, then you can try to open this file and check if you get an error.

 

Mike

Message 6 of 10
(15,286 Views)

I would like to know how to make a vi that checks and reads the new entry path using labview.Kindly rply me pls.

0 Kudos
Message 7 of 10
(12,441 Views)

You're replying to a 6 year old thread, that asks the same question as you, and answers it.  Please re-read the thread for your answer.

0 Kudos
Message 8 of 10
(12,410 Views)

Sorry sir.That message and .png file gives the code to check whether the path is valid or not.In my project there will be data logging everyday.So everyday a new log file has been created.What i need is to use that new log file each timewhen it has been created.Kindly help me pls

0 Kudos
Message 9 of 10
(12,365 Views)
That is a completely unrelated question. Start a NEW thread
with details on what you have tried and how you are creating the file names.

Message 10 of 10
(12,355 Views)