LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CVI, how do I check to see if a path exists?

I am writing an application that requires the user to select a path and filename for a new file to be created. How do I check to see if the path already exists/is valid?

Kay
0 Kudos
Message 1 of 6
(3,792 Views)
GetFileAttrs() returns 0 if path is an existing file, returns 1 if path is a directory, and -1 if path is not found.
Look at the function panel or on-line help for GetFileAttrs().
GetFileInfo() is a related function.
Message 2 of 6
(3,792 Views)
Thanks for the response. I finally found MakeDir and use it to check to see if the path exists. I am only checking the path and not the filename.

The MakeDir is working for me now. I'll look at using the GetFileAttrs() if this doesn't work out.

Thanks again,
Kay
0 Kudos
Message 3 of 6
(3,792 Views)
If your users are familiar with the typical file open dialog in Windows based programs, you may want to look at FileSelectPopup() or DirSelectPopup().
FileSelectPopup() is used in many of the sample programs that ship with CVI including
...\CVI\samples\userint\popups.prj.
With either popup, you have the option of allowing the user to create a new directory.
0 Kudos
Message 4 of 6
(3,792 Views)
Maybe the function MakeDir from CVIs Utility library can help you. This function creates a new directory but if the directory/file in directory still exists it will return error code -9 (see function panel help for more details).

Regards,
Heinrich Illig
National Instruments
Message 5 of 6
(3,792 Views)
Thanks!

That worked.

Kay
0 Kudos
Message 6 of 6
(3,792 Views)