Advertisement
Guest User

shit retard codess

a guest
Feb 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.43 KB | None | 0 0
  1.  
  2.         public Updater()
  3.         {
  4.             InitializeComponent();
  5.         }
  6.  
  7.         WebClient webClient;
  8.         Stopwatch staphxD = new Stopwatch();
  9.  
  10.         private void Updater_Load(object sender, string urlAddress, string location, EventArgs e)
  11.         {
  12.             DownloadUpdate(urlAddress, location);
  13.         }
  14.  
  15.         public void DownloadUpdate(string urlAddress, string location)
  16.         {
  17.             using (webClient = new WebClient())
  18.             {
  19.                 string path = @"LoaderPath.txt";
  20.  
  21.                 if (!File.Exists(path))
  22.                 {
  23.                     using (StreamWriter sw = File.CreateText(path))
  24.                     {
  25.                         sw.WriteLine(System.Reflection.Assembly.GetEntryAssembly().Location);
  26.                     }
  27.                 }
  28.  
  29.  
  30.  
  31.                 webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
  32.                 webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
  33.  
  34.  
  35.                 Uri URL = urlAddress.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? new Uri("google.com/idk.exe") : new Uri("http://" + urlAddress);
  36.  
  37.                 staphxD.Start();
  38.  
  39.                 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  40.                 var stringChars = new char[20];
  41.                 var random = new Random();
  42.                 for (int i = 0; i < stringChars.Length; i++)
  43.                 {
  44.                     stringChars[i] = chars[random.Next(chars.Length)];
  45.                 }
  46.                 var finalString = new String(stringChars);
  47.                 location = Directory.GetCurrentDirectory() + "/" + finalString + ".exe";
  48.  
  49.                 try
  50.                 {
  51.                     webClient.DownloadFileAsync(URL, location);
  52.                 }
  53.                 catch (Exception ex)
  54.                 {
  55.                     MessageBox.Show(ex.Message);
  56.                 }
  57.             }
  58.         }
  59.  
  60.         private void ProgressChanged(object sender , DownloadProgressChangedEventArgs e)
  61.         {
  62.             label6.Text = string.Format("{0} MB's / {1} MB's",(e.BytesReceived / 1024d / 1024d).ToString("0.00"),(e.TotalBytesToReceive / 1024d / 1024d).ToString("0.00"));
  63.             label5.Text = string.Format("{0} kb/s", (e.BytesReceived / 1024d / staphxD.Elapsed.TotalSeconds).ToString("0.00"));
  64.             progressBar1.Value = e.ProgressPercentage;
  65.             label7.Text = e.ProgressPercentage.ToString() + "%";
  66.         }
  67.  
  68.         private void Completed(object sender,AsyncCompletedEventArgs e)
  69.         {
  70.             staphxD.Reset();
  71.             var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  72.             var stringChars = new char[20];
  73.             var random = new Random();
  74.             for (int i = 0; i < stringChars.Length; i++)
  75.             {
  76.                 stringChars[i] = chars[random.Next(chars.Length)];
  77.             }
  78.             var finalString = new String(stringChars);
  79.  
  80.             string location = Directory.GetCurrentDirectory() + "/" + finalString + ".exe";
  81.  
  82.             if (e.Cancelled == true)
  83.             {
  84.                 MessageBox.Show("Download has been canceled.");
  85.             }
  86.             else
  87.             {
  88.                 MessageBox.Show("Download completed!");
  89.                 Process.Start(location);
  90.                 Application.Exit();
  91.  
  92.             }
  93.         }
  94.  
  95.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement