This should work for you:
string spanText = driver.findElement(By.cssSelector("div#flashMessage>span")).getText();
I'm not sure why the same locator wouldn't work for success messages, but you can try this:
string spanText = driver.findElement(By.cssSelector("div#flashMessage.msg>span")).getText();