protected bool ProcessIndex(PageInfo pi, ref Encoding encoding, out string content) { content = string.Empty; int count = 0; bool res = false; while (count < Retry) { res = FileDownloadUtil.DownloadWebPage(pi.Url, ref content, ref encoding); if (res) { break; } Logger.Instance.Error(string.Format("Download Page Failed! [{0}] = Index", count)); count++; } if (!res) { Logger.Instance.Error("Download Index Failed!"); return(false); } else { Logger.Instance.Info("Download Index OK!"); return(true); } }
private static bool DownloadUrl(string url, string saveTo, bool updateMode) { try { string saveToLoc = saveTo; if (File.Exists(saveToLoc) && !updateMode) { Logger.Instance.InfoImportant("Over write mode, Delete: " + new FileInfo(saveToLoc).Name); File.Delete(saveToLoc); } else if (File.Exists(saveToLoc) && updateMode) { Logger.Instance.InfoImportant("Update Mode, File Exists: " + new FileInfo(saveToLoc).Name); } if (FileDownloadUtil.DownloadFile(url, saveToLoc)) { Logger.Instance.Info(string.Format("Dwonload OK: {0}", url)); return(true); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(false); }