Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. namespace PicsDownloader
  2. {
  3.     public class StartUp
  4.     {
  5.         public static void Main()
  6.         {
  7.             Console.Write("File Path: ");
  8.             var filePath = Console.ReadLine();
  9.             var links = File.ReadAllLines(filePath);
  10.             var regex = new Regex("\\\\?\\w+.txt");
  11.  
  12.             var filaName = string.Join("", regex.Match(filePath).ToString().Skip(1).Reverse().Skip(4).Reverse());
  13.  
  14.             var client = new WebClient();
  15.             var count = 1;
  16.  
  17.             if (!Directory.Exists(filePath))
  18.             {
  19.                 Directory.CreateDirectory($@"C:\{filaName}");
  20.             }
  21.  
  22.             foreach (var link in links)
  23.             {
  24.                 client.DownloadFile(link, $@"C:\{filaName}\{count}.jpg");
  25.                 count++;
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement