0

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

3
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

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

0

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?

0

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, ...);
0

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'

Edited by darkdai: n/a

0

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);

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.