10-22-2013 03:33 AM
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
Solved! Go to Solution.
10-22-2013 04:02 AM
Have a look at this post, it should provide a solution to determine if a directory exists.
10-22-2013 04:42 AM
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
10-22-2013 08:47 PM
Hi,RobertoBozzolo :
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;
}
10-23-2013 12:05 AM
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.
10-23-2013 12:30 AM
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...
10-23-2013 03:24 AM
Hi,thank you for your reply,
10-23-2013 03:37 AM
Hi,thank you for your reply:
hat CVI i use is the FDS version 2009,You can view my upload attachments ‘FDS2009.png’
10-23-2013 04:07 AM - edited 10-23-2013 04:07 AM
OK, I think I got it. CVI cannot handle the #pragma comment line: you need to explicitly add the library to the project.
10-25-2013 02:07 AM