|
-
January 27th, 2003, 10:49 AM
#1
FindFirstFile() question
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 ata\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));
}
-
January 27th, 2003, 12:11 PM
#2
The truth is you cannot. You are responsible for appending on a path to the file. That is the way the API was designed.
Besides, you know what the path is. You passed it in yourself. Just parse the string if you need it and append it to each filename you need.
- Robert
-
January 27th, 2003, 12:42 PM
#3
OK thanks. I was going to do that but thought that I must have missed something in the API and didn't want to reinvent the wheel.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|