I was able to get the name of the database in what feels like a really hacky and uncertain way. However, this really works for me and I am just using this in a small test and development tool just for myself anyway.
If you follow the same answer as Mitch Wheat, what you need to do is the following:
Right after
restoreDB.Devices.AddDevice(@"D:\somepath\...\MyDBFull.bak", DeviceType.File);
Add these three lines:
var fileList = restoreDB.ReadFileList(myServer);
string databaseName = fileList.Rows[0].ItemArray[0].ToString();
restoreDB.Database = databaseName;
You read the associated file list using myServer and you get the information from a DataTable and an ItemArray. The name seems to be present in the first row and in the first item in the item array. After that, use this name to set the Database property of the restore object. Voilà, no need to provide your own database name if you simply want to restore or switch between existing databases whose names you don't really remember any more.
WARNING: This works only if your database has been created in the same instance in which you're restoring it. If you're using this method to restore databases created and backed up from elsewhere it will not work because there are more properties you will probably need to set!
Which properties you might ask? You will have to go and shop for yourself inside the ItemArray. Nevertheless, one of the properties is the location to which the database needs to be restored. You can also find the location in there. Stating the obvious but make sure the folder in which the database used to reside also exists on your computer!
Anyway, I tried this out with a couple of databases and this works for me and hope it helps anybody out there!