C++ Newbie
January 27th, 2003, 09:49 AM
Hi, I've been trying to use the FindFirstFile function for reading files from a given input directory. basically, at the command line I write:
ProcessTextFiles "c:\data\*.txt"
so that I pass in the directory string as shown above. Now, when I run the code snippet below, it seems to correctly go the directory I want and step through the .txt files one at a time but in the returned structure
WIN32_FIND_DATA fileData;
I can see that you can retrieve the current filename (i.e., with cFileName method) but only without the path. How can I used FindFirstFile in a way where I can get the entire path:
for example:
"c:data\gg1.txt"
vs just
"gg1.txt"
??
Thanks!
if ((hFileRead = FindFirstFile(argv[1], &fileData)) != INVALID_HANDLE_VALUE){
do{
string FilenameWithFullPath = fileData.cFileName;
//Process this next text file
BuildDictionary.ProcessTextFile(FilenameWithFullPath);
}while (FindNextFile(hFileRead, &fileData));
}
ProcessTextFiles "c:\data\*.txt"
so that I pass in the directory string as shown above. Now, when I run the code snippet below, it seems to correctly go the directory I want and step through the .txt files one at a time but in the returned structure
WIN32_FIND_DATA fileData;
I can see that you can retrieve the current filename (i.e., with cFileName method) but only without the path. How can I used FindFirstFile in a way where I can get the entire path:
for example:
"c:data\gg1.txt"
vs just
"gg1.txt"
??
Thanks!
if ((hFileRead = FindFirstFile(argv[1], &fileData)) != INVALID_HANDLE_VALUE){
do{
string FilenameWithFullPath = fileData.cFileName;
//Process this next text file
BuildDictionary.ProcessTextFile(FilenameWithFullPath);
}while (FindNextFile(hFileRead, &fileData));
}