Click here to Skip to main content
15,917,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: timeGetTime Thankyou Pin
wogerdoger30-Aug-03 8:53
wogerdoger30-Aug-03 8:53 
GeneralSetting Array SIZE....help! Pin
colormyiris30-Aug-03 0:34
colormyiris30-Aug-03 0:34 
GeneralRe: Setting Array SIZE....help! Pin
Abin30-Aug-03 0:48
Abin30-Aug-03 0:48 
GeneralRe: Setting Array SIZE....help! Pin
Simon.W31-Aug-03 2:34
Simon.W31-Aug-03 2:34 
GeneralRe: Setting Array SIZE....help! Pin
User 665830-Aug-03 1:13
User 665830-Aug-03 1:13 
GeneralRe: Setting Array SIZE....help! Pin
Mira30-Aug-03 1:20
Mira30-Aug-03 1:20 
Questionwhat do i make for my major project Pin
IT_student30-Aug-03 0:31
IT_student30-Aug-03 0:31 
AnswerRe: what do i make for my major project Pin
Beer2630-Aug-03 3:29
Beer2630-Aug-03 3:29 
GeneralRe: what do i make for my major project Pin
IT_student30-Aug-03 7:56
IT_student30-Aug-03 7:56 
GeneralRe: what do i make for my major project Pin
Maximilien30-Aug-03 8:48
Maximilien30-Aug-03 8:48 
GeneralRe: what do i make for my major project Pin
IT_student30-Aug-03 8:58
IT_student30-Aug-03 8:58 
GeneralRe: what do i make for my major project Pin
Simon.W31-Aug-03 2:41
Simon.W31-Aug-03 2:41 
GeneralRe: what do i make for my major project Pin
IT_student31-Aug-03 5:16
IT_student31-Aug-03 5:16 
GeneralRe: what do i make for my major project Pin
wogerdoger1-Sep-03 21:36
wogerdoger1-Sep-03 21:36 
QuestionRegistry ??? Pin
dirand8529-Aug-03 22:27
dirand8529-Aug-03 22:27 
AnswerRe: Registry ??? Pin
vcplusplus30-Aug-03 0:59
vcplusplus30-Aug-03 0:59 
GeneralRe: Registry ??? Pin
dirand8530-Aug-03 3:07
dirand8530-Aug-03 3:07 
GeneralCircular rotating Buttons.. Pin
cutti29-Aug-03 21:45
cutti29-Aug-03 21:45 
GeneralRe: Circular rotating Buttons.. Pin
PJ Arends29-Aug-03 22:56
professionalPJ Arends29-Aug-03 22:56 
GeneralAbout Float Point Exception Pin
HansonDavid29-Aug-03 20:52
HansonDavid29-Aug-03 20:52 
GeneralPROJECTS Pin
Neelesh K J Jain29-Aug-03 18:49
Neelesh K J Jain29-Aug-03 18:49 
GeneralRe: PROJECTS Pin
TigerNinja_29-Aug-03 18:54
TigerNinja_29-Aug-03 18:54 
GeneralWinAPI FindNextFile problem Pin
TigerNinja_29-Aug-03 18:36
TigerNinja_29-Aug-03 18:36 
Hi All,
I can not seem to get ::FindNextFile to work properly, or should I say the way I would expect it to work. The code below is straight out of MSDN, but it only works on the first file, the FindNextFile call returns FALSE, thus it does not iterate through the entire directory. I have a ton of .txt files, so it should find more than one.

Thanks in advance for any help or suggestions ?

<br />
#include <windows.h><br />
#include <stdio.h><br />
<br />
WIN32_FIND_DATA FileData; <br />
HANDLE hSearch; <br />
DWORD dwAttrs; <br />
char szDirPath[] = "c:\\TEXTRO\\"; <br />
char szNewPath[MAX_PATH]; <br />
char szHome[MAX_PATH]; <br />
 <br />
BOOL fFinished = FALSE; <br />
 <br />
// Create a new directory. <br />
 <br />
if (!CreateDirectory(szDirPath, NULL)) <br />
{ <br />
    printf("Couldn't create new directory."); <br />
    return;<br />
} <br />
 <br />
// Start searching for .TXT files in the current directory. <br />
 <br />
hSearch = FindFirstFile("*.txt", &FileData); <br />
if (hSearch == INVALID_HANDLE_VALUE) <br />
{ <br />
    printf("No .TXT files found."); <br />
    return;<br />
} <br />
 <br />
// Copy each .TXT file to the new directory <br />
// and change it to read only, if not already. <br />
 <br />
while (!fFinished) <br />
{ <br />
    lstrcpy(szNewPath, szDirPath); <br />
    lstrcat(szNewPath, FileData.cFileName); <br />
    if (CopyFile(FileData.cFileName, szNewPath, FALSE))<br />
    { <br />
        dwAttrs = GetFileAttributes(FileData.cFileName); <br />
        if (!(dwAttrs & FILE_ATTRIBUTE_READONLY)) <br />
        { <br />
            SetFileAttributes(szNewPath, <br />
                dwAttrs | FILE_ATTRIBUTE_READONLY); <br />
        } <br />
    } <br />
    else <br />
    { <br />
        printf("Couldn't copy file."); <br />
        return;<br />
    } <br />
 <br />
    if (!FindNextFile(hSearch, &FileData)) <br />
    {<br />
        if (GetLastError() == ERROR_NO_MORE_FILES) <br />
        { <br />
            MessageBox(hwnd, "No more .TXT files.", <br />
                "Search completed.", MB_OK); <br />
            fFinished = TRUE; <br />
        } <br />
        else <br />
        { <br />
            printf("Couldn't find next file."); <br />
            return;<br />
        } <br />
    }<br />
} <br />
 <br />
// Close the search handle. <br />
 <br />
FindClose(hSearch);<br />






R.Bischoff
.NET, Kommst du mit?


GeneralRe: WinAPI FindNextFile problem Pin
Michael Dunn29-Aug-03 19:08
sitebuilderMichael Dunn29-Aug-03 19:08 
GeneralRe: WinAPI FindNextFile problem Pin
TigerNinja_29-Aug-03 19:27
TigerNinja_29-Aug-03 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.