protected void btnUpload_Click(object sender, EventArgs e) { string sXML = String.Empty; if (upFile.HasFile) { using (StreamReader sr = new StreamReader(upFile.FileContent)) { sXML = sr.ReadToEnd(); } } string sTest = String.Empty; if (!string.IsNullOrEmpty(sXML) && sXML.Length > 500) { sTest = sXML.Substring(0, 250).ToLower(); try { if (sXML.Contains("<channel>") && sXML.Contains("<rss")) { int iChnl = sXML.IndexOf("<channel>"); sTest = sXML.Substring(0, iChnl).ToLower(); } if (sTest.Contains("<!-- this is a wordpress extended rss file generated by wordpress as an export of your") && sTest.Contains("http://purl.org/rss") && sTest.Contains("http://wordpress.org/export")) { WordPressSite wps = ContentImportExportUtils.DeserializeWPExportAll(sXML); ContentImportExportUtils.AssignWPExportNewIDs(SiteData.CurrentSite, wps); ContentImportExportUtils.SaveSerializedDataExport <WordPressSite>(wps.NewSiteID, wps); Response.Redirect(CreateLink("WPGalleryImport", String.Format("id={0}", wps.NewSiteID))); } lblWarning.Text = "File did not appear to match an expected format."; lblWarning.Attributes["style"] = "color: #990000;"; } catch (Exception ex) { lblWarning.Text = ex.ToString(); lblWarning.Attributes["style"] = "color: #990000;"; } } else { lblWarning.Text = "No file appeared in the upload queue."; lblWarning.Attributes["style"] = "color: #990000;"; } }