Hi,
A few threads ago I posted some notes and in another some code. This is
basically what you need
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
string Wild = Dirname;
if( !Wild.empty() )
{
if( *Wild.rbegin() != '\\' ) Wild += '\\';
}
string Dir = Wild;
Wild += "*.*";
hFind = FindFirstFileEx ( Wild.c_str(), FindExInfoStand ard, &FindFileDat a,
FindExSearchNam eMatch, NULL, 0 );
if (hFind == INVALID_HANDLE_ VALUE)
{
stringstream Error;
Error << "Invalid File Handle. GetLastError reports " << GetLastError ()
<< endl;
// NOTE if errorcode is 2 it isn't really an error ('no such file or
directory')
throw CInfoException( Error.str() );
}
else
{
do
{
//NOTE: Filename = FindFileData.cF ileName,
}
while( FindNextFile( hFind, &FindFileDat a ) );
FindClose(hFind );
--
Regards, Ron AF Greve
http://moonlit.xs4all.nl
"Peter Pippinger" <pe************ *@gmx.de> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
Hello NG,
I have written some code which worked fine under c#. But i donīt know,
how this shoud work in c++. I have tryed much things, but i canīt find
out how to use DirectoryInfo and FileInfo under c++.
Thanks for any hints!
Peter
Here is the c# code:
//
---------------------------------------------------------------------
// -- View *.prn Files in Directory
//
---------------------------------------------------------------------
void Btn_aktualisier enClick(object sender, System.EventArg s e)
{
// clear listview
lv_fileliste.Cl ear();
DirectoryInfo dir = new DirectoryInfo(" c:\\");
FileInfo[] fileInfo = dir.GetFiles("* .prn");
// Insert files in listview
foreach ( FileInfo fi in fileInfo )
{
lv_fileliste.It ems.Add(fi.Name .ToString(),0);
}
}