Read filename from SD card, store to a string

I have this, which I posted above

// open next file in root.  The volume working directory, vwd, is root
  while (sdCardFile.openNext(sdCard.vwd(), O_READ)) 
{
  MaxFiles++;
    
  sdCardFile.close();
}

And I essentially want to do something like this:

// open next file in root.  The volume working directory, vwd, is root
  while (sdCardFile.openNext(sdCard.vwd(), O_READ)) 
{
  MaxFiles++;
  sdCardFile.printName(??) //But I dont want to print to a serial stream, I want to print to a int, or a string
    
  sdCardFile.close();
}

Cheers