I am working on a project named "file crawler" in visual c++. It will simply index all the files of a specified directory in a file. The user can search this c++ file for a particular file through extension, name etc.
Right now, I want to get all the file names and directories into an object of my created class. I found this code helpful:
using namespace System;
using namespace System::IO;
int main()
{
DirectoryInfo^ di = gcnew DirectoryInfo( "d:\\" );
array<FileInfo^>^fiArr = di->GetFiles();
Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
while ( myEnum->MoveNext() )
{
FileInfo^ fri = safe_cast<FileInfo^>(myEnum->Current);
Console::WriteLine( fri->Name );
}
}
The problem is that this code uses the file info handle and I don't know how to transfer all this data to an object that will be a pointer in a directory class (my class).
My class is like this:
class directories
{
ffile *file; ddirectory *sdirectory
string path;
};
I also need the explanation of:
Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
I am doing second year of graduation. Please suggest some ideas to me. I have 20 days to complete this project.