Advertisement
4_2005-2006 Complete Applications #160863

Easy directory listing

This is an EASY example of listing files in a directory. I got this example from another post, but i could not get that post to work, so i modified it and made it easy to use. I'm using this in a new program i am working on.

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
#include <iostream.h>
#include <windows.h>

int GetDir(char* dPath) {
	
	WIN32_FIND_DATA FileData;
	HANDLE hFile;
	hFile = FindFirstFile(dPath,&FileData);
	
	if ( INVALID_HANDLE_VALUE == hFile ) {
		cout << "No files" << endl;
		return false;
	}
	for ( ;; )	{
		cout << FileData.cFileName << endl;
    if ( 0 == FindNextFile(hFile, &FileData ) )
			break;
  	}
	return true;
}
int main() {
	GetDir("c:\\*.txt");

	return true;
}
Původní komentáře (3)
Obnoveno z Wayback Machine