LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get File Dialog 's file name

Solved!
Go to solution

Dear all,

 

I use File Dialog to open a file and read the content of it. However, I want to show the name of the opened file and don't know how to do it.

 

Anybody has an idea to display the name of the opened file?

 

Thanks. Smiley Happy

0 Kudos
Message 1 of 8
(10,803 Views)
Solution
Accepted by topic author powerplay

Hi powerplay,

the File Dialog has an "selected path" output. You can use the strip path function to get only the filename.

 

Mike

Message 2 of 8
(10,799 Views)

The express VI in the Advanced File I/O functions?

 

It has an output that is the selected file path.  You can wire an indicator to that.

0 Kudos
Message 3 of 8
(10,796 Views)

I think you use the pop-up from the 'read from file' primitive, to get the file name use the following code:

Refnum to Path.png

The Refnum to Path will read the data at the file reference and returns it actual path.

 

Ton

 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 4 of 8
(10,795 Views)

thanks for your prompt replies. I really appreciate that. 

 

Smiley Very Happy 

 

0 Kudos
Message 5 of 8
(10,787 Views)

Warning:

This technique {Refnum to Path} does not appear to work with configuration (.ini) files having Sections and Keys.

0 Kudos
Message 6 of 8
(4,019 Views)

No.  It won't.  Because the refnum the Config functions use is not a file refnum, but a refnum for a queue.

 

The queue is a single element queue and the cluster that defines the queue has the file refnum as an element within it, along with the config data and a boolean flag.

 

You can open up the Config File subVI's to see how they handle the file reference.  It basically wraps the information up in a single cluster and guards against simultaneous access using a a single element queue size.

 

But I don't know of a reason to ever use the technique in this thread.  If you ever generate a file reference, then you had to open a file with a known file path.  Just carry along that file path/name to where you need it rather than trying to back out the file name from the reference wire.

0 Kudos
Message 7 of 8
(4,005 Views)

@johnwhitcraft wrote:

Warning:

This technique {Refnum to Path} does not appear to work with configuration (.ini) files having Sections and Keys.


There's a separate function for that in the "Configuration File VIs" palette: "Not A Config Data Refnum.vi"

"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 8
(3,984 Views)