Using 2nd SPI Port with SD Library (ESP32)

Hello,

i have a project with an display and an sd card. Since both need an SPI Port i need to use the second Port for the SD card.

I use the ESP32 DevKit with 30 Pins.

bool EKG_recording::initialisation_sd() {

  SPIClass * hspi = new SPIClass(HSPI);

  if (!SD.begin(CS_Pin, *hspi))
  {
    Serial.println("No valid SD Card!");
    return 0;
  }

  else if (SD.begin(CS_Pin, *hspi))
  {
    Serial.println("SD Card initalized");
    return 1;
  }
  else return 0;
}

This part works. The SD Card gets detected no problem. But then when i try to call this function

unsigned short EKG_recording::count_files_from_SD(File dir) {

  dir.rewindDirectory();

  while (true)
  {
    File entry = dir.openNextFile();

    while (entry.isDirectory()) { //check if open file is folder or not
      Serial.println("Still Directory");
      entry = dir.openNextFile();     //if folder open nextFile until file is found instead of folder
    }
    
    Serial.println("This is counter:");
    Serial.println(counter);
    if (!entry)
    {
      Serial.println(counter);
      return counter;
    }
    Serial.println("It counted Up");
    counter++;
    entry.close();
  }

}

it just returns 0. I know for a fact that i have 3 files on this sd card. This means that entry = FALSE. But why?

Anybody has a clue what could be wrong? Before i used 2 SPI Ports this would actually work, so what has changed?