LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Will there CVI API functions that search fo a given path of the exists file ? such as 'DirectoryExists'

Solved!
Go to solution

Will there CVI API functions that search fo a given  path of the exists file ? such as C + + Builder's 'DirectoryExists', I tried 'FileExists', but unuseful

0 Kudos
Message 1 of 16
(4,618 Views)

Have a look at this post, it should provide a solution to determine if a directory exists.

Message 2 of 16
(4,614 Views)

This sounds as a trick that backs up to good old DOS days, and I don't remember very well how it works: a simple dot is somewhat mapped to the directory name, so you can test if C:\\TEMP folder exists by using:

FileExists ("c:\\temp\\.", NULL);

 

Alternative 2: use GetFirstFile to test for directories:

GetFirstFile ("c:\\temp", 0, 0, 0, 0, 0, 1, file);

 

Alternative 3: use PathFileExists from the Windows API

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 16
(4,612 Views)

Hi,

          Thank you for your advice, I have try 'PathFileExists', but it comes an link error:
1 Project link error
 Undefined symbol '_PathFileExistsA@4' referenced in "uipara.c".

 

     Also I have included head file "Shlwapi.h" and its lib "Shlwapi.lib" :

#include "Shlwapi.h"

#pragma   comment(lib, "Shlwapi.lib")        //is it CVI can not write this?

but it do work in VC6 or VS2012...

 

Currently what I'm using is 'fopen' , if its return value is NULL, it means that the path of the file does not exist

if ( fopen ( Path, "r") == NULL)
{
      //do;

}

0 Kudos
Message 4 of 16
(4,596 Views)

Being part of the Windows API, PathFileExists need windows.h to be included too in the source code.

 

The return value from fopen does not tell you that the path does not exist: it tells you that the file cannot be accessed because either the file itself or its path do not exist.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 16
(4,592 Views)

If I remember correctly, in order to use the Win API you also need the FDS version of CVI, the base packages is not sufficient...

0 Kudos
Message 6 of 16
(4,591 Views)

Hi,thank you for your reply,

      I am sorry about that, i  forgetten to tell you that  i have include this file too. And it also comes an link error.
#include<Windows.h>
#include"Shlwapi.h"
#include <userint.h>
#include <utility.h>
 
#pragma  comment(lib, "Shlwapi.lib")

 

0 Kudos
Message 7 of 16
(4,586 Views)

Hi,thank you for your reply:

       hat CVI i use is the FDS version 2009,You can view my upload attachments ‘FDS2009.png’

 

0 Kudos
Message 8 of 16
(4,583 Views)

OK, I think I got it. CVI cannot handle the #pragma comment line: you need to explicitly add the library to the project.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 16
(4,575 Views)
 Hi:
      I'm sorry about that  reply to you later, I'm learn to CVI first, can you tell me how to add library files to my project?
 
 
Now i have a new question,the same as
'Change language dynamically in cvi'
i try the NI Example Finder that comes with CVI: running it on localize returns intgraph.cws,but i can't find the Interface Localization Tool (localui.fp)
 
0 Kudos
Message 10 of 16
(4,542 Views)