private List <ImageFileInfo> ParseXML(string value) { var fileInfo = new List <ImageFileInfo>(); if (value.StartsWith("<") && value.EndsWith(">")) { //Value is XML var xmlDoc = XDocument.Parse($"<images>{value}</images>"); foreach (var item in xmlDoc.Descendants("image")) { var imgFile = new ImageFileInfo(); var xAttribute = item.Attribute("modified"); if (xAttribute != null) { imgFile.ModifieDateTime = DateTime.Parse(xAttribute.Value); } imgFile.Url = item.Value; fileInfo.Add(imgFile); } } return(fileInfo); }
private static void DownloadFile(string localFile, ImageFileInfo item) { //Ensure Path exists var path = Path.GetDirectoryName(localFile); if (!Directory.Exists(path) && path != null) { Directory.CreateDirectory(path); } //Set remote hostname var remoteUri = new UriBuilder(item.Url); //Download file var webclient = new WebClient(); webclient.DownloadFile(remoteUri.Uri, localFile); }