Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.IO;
- using System.Security.Cryptography;
- namespace Uploader
- {
- public partial class Form1 : Form
- {
- //static public string filename = "";
- public Stream reqStream;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- // try
- // {
- // Application.DoEvents();
- // MessageBox.Show(reqStream.Position.ToString());
- //progressBar1.Value = (Int32)
- // ((reqStream.Position * 100) / reqStream.Length);
- // }
- // catch (Exception se) { }
- }
- protected string MD5(string fileName)
- {
- if (!File.Exists(fileName)) return "CHUJ";
- FileStream file = new FileStream(fileName, FileMode.Open);
- MD5 md5 = new MD5CryptoServiceProvider();
- byte[] retVal = md5.ComputeHash(file);
- file.Close();
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < retVal.Length; i++)
- {
- sb.Append(retVal[i].ToString("x2"));
- }
- return sb.ToString();
- }
- public void upload()
- {
- string user = File.ReadAllText("user.txt");
- string password = File.ReadAllText("password.txt");
- string destination = File.ReadAllText("destination.txt");
- string[] get = File.ReadAllLines("links.txt");
- System.Net.WebClient c = new System.Net.WebClient();
- foreach (string link in get)
- {
- //MessageBox.Show(link.LastIndexOf("/").ToString());
- string linkfile;
- if (link.IndexOf("download.php?") != -1) linkfile = "gmer.exe"; else
- linkfile = link.Substring(link.LastIndexOf("/")+1, link.Length - link.LastIndexOf("/")-1);
- //MessageBox.Show("links\\" + linkfile + ".down");
- c.DownloadFile(link, "links\\" + linkfile + ".down");
- if(MD5("links\\" + linkfile + ".down")
- != MD5("links\\" + linkfile)){
- File.Delete("links\\" + linkfile);
- File.Move(
- "links\\" + linkfile + ".down",
- "links\\" + linkfile
- );
- FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(destination + linkfile));
- request.Method = WebRequestMethods.Ftp.UploadFile;
- request.Credentials = new NetworkCredential(user, password);
- request.UsePassive = true;
- request.UseBinary = true;
- request.KeepAlive = false;
- FileStream stream = File.OpenRead("links\\" + linkfile);
- byte[] buffer = new byte[stream.Length];
- stream.Read(buffer, 0, buffer.Length);
- stream.Close();
- //label1.Text = linkfile;
- reqStream = request.GetRequestStream();
- for (int i = 0; i <= buffer.Length / 100; i++)
- {
- if ((i * 100) + 100 <= buffer.Length)
- reqStream.Write(buffer, i * 100, 100);
- else reqStream.Write(buffer, i * 100, buffer.Length - (i * 100));
- //progressBar1.Value = ((i * 10000) / buffer.Length);
- }
- reqStream.Close();
- }
- }
- // progressBar1.Value = 100;
- MessageBox.Show("Done");
- Application.ExitThread();
- Application.Exit();
- }
- private void Form1_Shown(object sender, EventArgs e)
- {
- Application.DoEvents();
- //timer1.Enabled = true;
- System.Threading.ThreadStart parameter = new System.Threading.ThreadStart(upload);
- System.Threading.Thread lol = new System.Threading.Thread(parameter);
- lol.Start();
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- Application.Exit();
- }
- private void Form1_ResizeBegin(object sender, EventArgs e)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment