public void DecorateFile (string path, string filename, MD5 checksum, Encoding enc)
{
string newline = Environment.NewLine;
var sb = new StringBuilder ();
sb.AppendFormat ("#ExternalSource(\"{0}\",1){1}", filename, newline);
byte[] bytes = enc.GetBytes (sb.ToString ());
using (FileStream fs = new FileStream (path, FileMode.Open, FileAccess.Write)) {
fs.Seek (enc.GetPreamble ().Length, SeekOrigin.Begin);
fs.Write (bytes, 0, bytes.Length);
bytes = null;
sb.Length = 0;
sb.AppendFormat ("{0}#End ExternalSource{0}", newline);
bytes = enc.GetBytes (sb.ToString ());
fs.Seek (0, SeekOrigin.End);
fs.Write (bytes, 0, bytes.Length);
}
sb = null;
bytes = null;
}
}