public static void DownloadLinks() { foreach (string EndVal in FoundLinks) { try { Uri url = new Uri(EndVal); string sourcehtml = HttpMethods.Get(EndVal, EndVal, ref HttpMethods.cookies); Uri uriResult; bool result = Uri.TryCreate(EndVal, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); string lastSegment = url.Segments[url.Segments.Length - 1]; string FileName; if (lastSegment.Substring(lastSegment.Length - 1) == "/") { FileName = "default-down.html"; } else { FileName = lastSegment; } try { if (EndVal.Trim() != string.Empty && result) { if (mainUri.Host == url.Host) { if (!Directory.Exists(dlpath + url.Host)) { Directory.CreateDirectory(dlpath + url.Host); } if (!Directory.Exists(dlpath + url.Host + Path.GetDirectoryName(url.AbsolutePath))) { Directory.CreateDirectory(dlpath + url.Host + Path.GetDirectoryName(url.AbsolutePath)); } //File.WriteAllText(url.Host + Path.GetDirectoryName(url.AbsolutePath) + "\\" + FileName, sourcehtml); if (!File.Exists(dlpath + url.Host + Path.GetDirectoryName(url.AbsolutePath) + "\\" + FileName)) { WebClient client = new WebClient(); client.DownloadFile(url, dlpath + url.Host + Path.GetDirectoryName(url.AbsolutePath) + "\\" + FileName); } } } } catch (Exception ex) { Errors.Add(ex.Message); } downloaded++; try { VisitedLinks.Add(url.ToString()); } catch (Exception ex) { Errors.Add(ex.Message); } int toplamdosya = FoundLinks.Count + ImageLinks.Count + CSSLinks.Count + JSLinks.Count + Analyzed.Count; Console.Title = string.Format("İndiriliyor... ({0} dosyadan {1} tanesi indirildi)", toplamdosya, downloaded); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write("İndirildi: "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(url); } catch (NullReferenceException ex) { Errors.Add(ex.Message); } catch (ArgumentOutOfRangeException ex) { Errors.Add(ex.Message); } catch (Exception ex) { Errors.Add(ex.Message); } } }