SD Library function doesnt work while using second SPI port with ESP32
Ok i found the solution. It was not too complicated. I just assumed the problem was in the code. This works well enough (dont ask me about the counter--)

  unsigned short EKG_recording::count_files_from_SD() {

  root = SD.open("/");
  root.rewindDirectory(); //Sets to beginning of directory


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

    if(!entry){
      Serial.println("Anzahl der Daten");
      counter--;
      return counter;
    }
    counter++;
    entry.close();
  }
}


It was just because i used SD.open() always inside the class-functions, so every file root was bound to the class.