I have a SharePoint Event Receiver for a feature that I am writing. On the FeatureActivated method, I want to add a control to the SharePoint Master Pages. In order to do this, I have elected to inject some text into the master page to add the control by opening the the file with a StreamReader, reading the stream to text, inserting the text, then saving the file back with a SharePoint Object model.
I'm having an issue with the StreamReader. When it reads the stream to text, all I get back are a bunch of question marks.
Here is the code:
foreach(SPFile file in files)
{
    switch(new FileInfo(file.Name).Extension)
    {
        case ".master":
            string masterString = string.Empty;
            using(StreamReader reader = new StreamReader(file.OpenBinaryStream()))
            {
                masterString = reader.ReadToEnd();
            }
            //
            // Inject the text I want into the masterString
            // Convert masterString into byte []
            // Save the byte [] back to SharePoint, overwriting the master 
            // page                          
            //
            break;
    }
}
The masterString always comes back as ???????????????????????.... I need it to come back as plain text.
Any ideas?
 
    