You can remove all spaces with this regex
content = Regex.Replace(content, @"\s+", string.Empty);
what are whitespace from MSDN .
Btw you are mistaken Trim with removing spaces, in fact it is only removing spaces at the beginning and at the end of the line. If you want to replace all spaces and carige returns, use my regex.
source share