Thank you, Tom. This is helpful and instructive, although my method was
working, I believe, with the same results.
Since you are trying to use an interesting file name format you may find
my class that does regular expression patterns for file name useful.
http://www.codeproject.com/KB/files/CFileFindEx.aspx
In any event you need to call CFileFind in a certain way:
CFileFind fileInfo;
BOOL bWorked = fileInfo.FindFile(csFilePath);
if(bWorked) {
do {
bWorked = fileInfo.FindNextFile(); // Have to call
FindNextFile() before using the first file
// Do something with the files...
} while(bWorked);
}
Tom
"SteveR" <maxsrussellatremovethisembarqmail.com> wrote in message
news:OnKFQkcoIHA.5836@TK2MSFTNGP04.phx.gbl...
Okay, after doing a little more study, I have found that an additional
call to filearray.Add(file.GetFilePath()); -- after
while(file.FindNextFile() ) fails -- allows me to add that first
filename.
------------------------
"SteveR" <maxsrussellatremovethisembarqmail.com> wrote in message
news:u7txNVcoIHA.2636@TK2MSFTNGP04.phx.gbl...
Perhaps my problem would be more correctly stated as: FindFile() does
not allow me to call GetFilePath(), and therefore I do not know how to
extract that first filename.
------------
"SteveR" <maxsrussellatremovethisembarqmail.com> wrote in message
news:%23DwLsPcoIHA.3556@TK2MSFTNGP04.phx.gbl...
I am running a search for audio files that contain a given word in their
names. In the case of the example provided here, there is only one
filename containing "Ay.", and that is the file "Ay." (Ay..ogg). But
after my wildcard search finds that file, it advances past it, so that
FindNextFile( ) leaves me with no results. So actually, the same
problem occurs with my successful searches. I never get to use the
first file found.
Would someone mind steering me into a better methodology here?
CString word = _T("Ay.");
CString s = GetFolderPath( )
+ _T("\\*")
+ word
+ _T("*")
+ _T(".ogg");
CFileFind file;
if(!file.FindFile(s) )
file.Close();
while(file.FindNextFile() )
filearray.Add(file.GetFilePath());
file.Close();