Advertisement
Seregamil

Send files

Oct 1st, 2013
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Net;
  7. using System.IO;
  8.  
  9. namespace ForAll
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.WriteLine("Download process started");
  16.             if (!File.Exists("download.txt"))
  17.             {
  18.                 Console.WriteLine("File 'download.txt' is not exist");
  19.                 Console.WriteLine("Press 'Enter' to continue");
  20.                 Console.ReadKey(true);
  21.                 return;
  22.             }
  23.             Console.WriteLine("\nProcess:\n");
  24.             string line;
  25.             StreamReader file = new System.IO.StreamReader("download.txt");
  26.             while ((line = file.ReadLine()) != null)
  27.             {
  28.                 WebClient client = new WebClient();
  29.                 try
  30.                 {
  31.                     Console.WriteLine("\tLoading: " + line);
  32.                     client.DownloadFile(line, "models/" + EditText(line));
  33.                 }
  34.                 catch (Exception ex)
  35.                 {
  36.                     Console.WriteLine(ex.ToString());
  37.                     Console.WriteLine("Press 'Enter' to continue");
  38.                     Console.ReadKey(true);
  39.                     return;
  40.                 }
  41.             }
  42.             file.Close();
  43.             Console.WriteLine("All files loaded!\nPress 'Enter' to continue");
  44.             Console.ReadKey(true);
  45.         }
  46.         public static string EditText(string text)
  47.         {
  48.             for (int j = text.Length - 1; j != 0; j--) if (text[j] == '/') return text.Remove(0,j+1);
  49.             return text;
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement