LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetFirstFile() return files is not correct

I use GetFirstFile()  to search the files in folder,most time is ok,but sometimes get error result ,for example , I search *30a*, the result is the file "YP09040882E.csv",search "30b",the result is"YP090408B0D.csv",it is strange, only occus in specific file name.

my code is :

 sprintf(ctemp,"\\*%s*",cYpText);  
 strcat (searchPath, ctemp);
        
 
 if (!GetFirstFile (searchPath, 1, 1, 0, 0, 0, 0, fileName))  {

........

}

0 Kudos
Message 1 of 22
(4,400 Views)
You are saying this only happens sometimes - is this not reproducible every time? The "*30a*" search pattern should not result in a match to a file named "YP09040882E.csv". Try printing out the searchPath when this happens to make sure that variable has the expected value - may be searchPath is getting trashed for some reason. Also, if you program is multithreaded make sure your variables (ctemp, cYpText, searchPath, and fileName) are are not being used in multiple threads.
Message Edited by Mohan on 02-23-2009 03:17 PM
0 Kudos
Message 2 of 22
(4,379 Views)

Hi Mohan,

thanks your quick reply.

this issue can reproducible. this issue is only found in some searching word, give you another sample,search the word "*34*",get result is "YP090409006""YP090408634"....,  you can see,"YP090409006" is wrong,see picture below show the code the variables :

 

0 Kudos
Message 3 of 22
(4,366 Views)

I am a little bit afraid that I missed something very basic, but the help of GetFirstFile says, that the searchpath can contain the wildcard character *.

So including this wildcard should indeed return _any_ file, including YP09040882E...? No?

 

Wolfgang

0 Kudos
Message 4 of 22
(4,356 Views)

Hi,

I use sample "filebrowsing" which from NI and only change the search path to "d:\1\*34*", and run the program, see the result below, in folder"d:\1" have 4 files, searching result is 2 files,one is not correct,could you help me explain what happened? how can I get the correct result?

0 Kudos
Message 5 of 22
(4,348 Views)

Hi,

I use sample "filebrowsing" which from NI and only change the search path to "d:\1\*34*", and run the program, see the result below, in folder"d:\1" have 4 files, searching result is 2 files,one is not correct,could you help me explain what happened? how can I get the correct result?

 

0 Kudos
Message 6 of 22
(4,349 Views)

sorry, I can not assist further, because none of your pictures is displayed in my browser (IE7)...

Wolfgang

0 Kudos
Message 7 of 22
(4,339 Views)

ttagiio,

 

To attach pictures to your post, click on the add attachments link below the message field and attach your screenshot.  You can embed a picture in your post if it is uploaded on the internet somewhere, but if you just have the picture on your computer, you should just attach it to your post.

Eric B.
National Instruments
0 Kudos
Message 8 of 22
(4,328 Views)

Hi ttagio,

 

Which version of CVI are you using? What is the path of the "filebrowsing" example? Also, can you attach the four files in your d:\1 folder, or give the names of these files?

 

0 Kudos
Message 9 of 22
(4,321 Views)
Thanks,add my code and 4 files in 1.zip and run result in 1.jpg.
Download All
0 Kudos
Message 10 of 22
(4,297 Views)