The reason why is involves some history of Arduino. It's really just C++ and from the beginning everything used ordinary C strings. Even though the String C++ class was added to Arduino about 10 years ago, the reality is most libraries still only accept C type strings.
So to give a C++ String to a function which wants a C string, you need this:
myFile = SD.open(filename.c_str(), FILE_WRITE);