How to assign (Root)Folder ID in C++? Wherein, those files and folder under it would have the same ID as the RootFolder

122 views Asked by At

This is my code and I would like to have a folder id, and those files and folders under the folder would have the same id. If you have any clarifications please do comment below. Thanks Also the id below inside the code is just to use the var id that I passed on the parameter of this function. It doesn't do anything.

public: list<cFolder> ScanMyDir(String^ SourceDir, String^ tab,list<cFolder> folderList, int id)
{
    tab += "     ";
    cFolder tempFolder; //used to store folder info
    string folderName;
    getFileDirInfo gfdi;

    array<String^> ^SubDirEntries = Directory::GetDirectories(SourceDir);
    for each (String^ subdir in SubDirEntries){
        if ((File::GetAttributes(subdir) & FileAttributes::ReparsePoint) != FileAttributes::ReparsePoint){   

            rtbxDir->AppendText(++id + tab + Path::GetFileNameWithoutExtension(subdir) + "\n"); //add to rich textbox
            gfdi.MarshalString(Path::GetFileNameWithoutExtension(subdir), folderName); // convert filename to std c++ string

            tempFolder.setFolderInfo(id, folderName);
            folderList.push_back(tempFolder); // add to folderlist
            folderList = ScanMyDir(subdir, tab, folderList, id);
        }
    }
   array <String^> ^fileEntries = Directory::GetFiles(SourceDir);
    for each  (String^ fileName in fileEntries)
    {
        rtbxDir->AppendText(tab + Path::GetFileName(fileName) + "\n");
    }
    return folderList;
}
0

There are 0 answers