C# • Implement a Web Service Updater.

Listing 1. One of the key components in this solution that enables you to signal whether you need to update a given app created with the Compact Framework. The specific tasks accomplished by the Web service are straightforward. Essentially, the Web service determines whether a given application needs to be updated, and if so, determines which files need to be updated. The Web service then provides the necessary files to complete the required update.

public string GetBinaries(string FileListXml)
   XmlDocument xDoc = new XmlDocument();
   System.Xml.XmlAttribute xa; 
   foreach(XmlNode n in xDoc.DocumentElement.ChildNodes)
      xa = xDoc.CreateAttribute("value");
      xa.Value = GetBase64StringFromFile
      //add the base64string to the node

   //send back the document as we received it, with 
   //the addition of the base64 binary strings
   return xDoc.InnerXml;

private string GetBase64StringFromFile(string file)
   //Open the file, and load it into the FileStream
   FileStream inFile = 
      new FileStream(file,FileMode.Open,
   byte[] binaryData = new Byte[inFile.Length];
   long bytesRead = inFile.Read(binaryData, 0,(int)inFile.Length);

   //Convert the byte array to a base64 string
   return System.Convert.ToBase64String(