Using a strng variable to open a new file on a SD card

Dear all!! I hope you are fine.

I have successfully created files on a SD card, using the SD.h library, and so on.
Now, I need to create more files on the same SD card, using variable filenames, such as Data1.txt, Data2.txt, and so on.
To make this, I have used the following code:

  int FileNumber;
  String NewFileName = "Data"
  File DataFile;

  FileNumber=2;
  
  NewFileName = NewFileName + FileNumber + ".txt";
  Serial.println(NewFileName);    // It should send "Data2.txt"

  DataFile = SD.open(NewFileName,FILE_WRITE);

and the next error poped-up:
"no matching function for call to 'SDClass::open(String&,int')

Im trying to concatenate strings and save the resulting string in the NewFileName variable, mixing strings with integers. I guess, that this is the problem. But I don't know, how to fix it... What can I do, to make that this code works?
Excuse me for my english.

Thank you very much!!

What can I do, to make that this code works?

You might try changing the String "data" into a null terminated string array.

Dear Zoomkat,
I'm reading about null terminated string arrays.
But, anyway, can you explain me a little bit more about the correct form to open this new file on the SD card? Like a example code?
Thank you!!

The below might be of use.

char buffer[20];
readString.toCharArray(buffer, 20);

StickFix:
and the next error poped-up:
"no matching function for call to 'SDClass::open(String&,int')

Im trying to concatenate strings and save the resulting string in the NewFileName variable, mixing strings with integers. I guess, that this is the problem. But I don't know, how to fix it... What can I do, to make that this code works?

 DataFile = SD.open(NewFileName.c_str(), FILE_WRITE);

It seems easier to me to just declare a c-string (null-terminated char array) to hold your filename.

char filename[16]; // make it however long you need
snprintf(filename, sizeof(filename), "data%d.txt", fileNumber);
DataFile = SD.open(filename, FILE_WRITE);

If you expect to use more than ten files and want them to list alphabetically in number order then you probably want your number to be printed with leading zeros. For example if you replace %d with %02d it'll produce two digits with leading zeros as required. The printf() and related functions are standard, well documented and extremely powerful for constructing string values.