Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3026

Listing all the files in a directory

$
0
0
Thanks for your previous help.

https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx

Would this code fragment successfully output to file c:\mylist\list1.txt a list of the names of all the files & subdirectories in directory c:\qwerty\ ?

Code:

{
struct _WIN32_FIND_DATA foundfileinfo;
HANDLE dsh,dh; FILE filelist=fopen("c:\\mylists\\list1.txt","w");
dsh=FindFirstFile("c:\\qwerty\\*.*",foundfileinfo);
if(dsh==INVALID_HANDLE_VALUE) goto NOTFOUND;
WORKONFILE: sprint(filelist,"%s\n",foundfileinfo.cFileName);
dh=FindNextFile(dsh,lpFindFileData);
if(dn) goto WORKONFILE;
NOTFOUND: fclose(filelist);
FindClose(dsh);
}

Would a wildcard code *.* find a file whose name does not end in a dot and a filetype code\?

Viewing all articles
Browse latest Browse all 3026

Trending Articles