Opening a SD Card for Read/Write

Good day,

I'm having a problem opening a SD card. I think I'm doing it wrong.
Is it the datatype? First part works fine.
I have a snippet of the code I have been using below for testing.

Thanks
Randy

String test = ""; 
  if (file == 0) 
   {
       strcpy_P(prog_buffer, (char*)pgm_read_word(&(string_table[4])));       
     upcFile = SD.open(prog_buffer, FILE_WRITE);
   } 
  else 
   { 
      test = getSeq(SEQ) + ".txt";
     Serial.println(test);
      upcFile = SD.open(test, FILE_WRITE);     // Error here. Because "test" is a string?
   }

Error here. Because "test" is a string?

No. The error is there because test is a String, not a string.

There is no reason for test to be a String. Make it a string (a NULL terminated array of chars) and it will work.

Use sprintf() to populate the array.