hey everyone, i was wondering if anyone can tell me how to prompt the user the enter the filename to be searched for using FindFirstFile. and if there a way of setting a default path to search in

Recommended Answers

All 5 Replies

Output a prompt asking for filename
Input as string
Use the string in FindFirstFile() as per the definition of the function.

but with the FindFirstFile() function, on you are supposed to enter the the path and the filename of which you are going to search for, so how can you icnlude both of those together in one?

If you enter *.* from the keyboard then just concantinate the two strings. Simple.

char path[255] = {"c:\\myfolder\\};
char file[] = "*.*';

strcat(path,file);
FindFirstFile(path, ...);

i have tried your method but it didnt work.

here is my implementation if the code:

char path[260]={"C:\\Users\\"};
   char filename[30]="*.*";
   strcat(path,filename);
    hFind = FindFirstFile(path, &FindFileData);

but i get an error that says:

error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char [260]' to 'LPCWSTR'

You are compiling for UNICODE. Either turn UNICODE off or make the string literals UNCODE compatible.

#include <tchar.h>
...
<snip>
 TCHAR path[260]={_TEXT("C:\\Users\\")};
   TCHAR filename[30]=_TEXT("*.*");
   _tcscat(path,filename);
    hFind = FindFirstFile(path, &FindFileData);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.