Click here to Skip to main content
15,892,072 members
Articles / Web Development / ASP.NET

Simple Upload File to Rapidshare Account Method using C#

Rate me:
Please Sign up or sign in to vote.
4.65/5 (12 votes)
2 Apr 2009GPL3 90K   963   32  
By using this C# (.NET 2.0) method, you can easily upload your files to Rapidshare.com account
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QUploadToRapidshare
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private string FilePath;
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();

        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            FilePath = openFileDialog1.FileName;
            textBox1.Text = FilePath;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "") openFileDialog1.ShowDialog();
            button2.Enabled = false;
            button2.Text = "Please Wait...";
            backgroundWorker1.RunWorkerAsync();
        }

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            QRapidshare QRapid = new QRapidshare();
            int type = 0;//Free User
            if (radioButton1.Checked)
            {
                type = 1;//Premium User
            }
            else if (radioButton2.Checked)
            {
                type = 2;//Collector User
            }

            string result = QRapid.QUploadToRapidshare(FilePath, textBox2.Text, textBox3.Text, type);
            if (result.StartsWith("<!")) result = "Login failed!";
            e.Result = result;
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            richTextBox1.Text = e.Result.ToString();
            button2.Enabled = true;
            button2.Text = "Upload";
        }

        private void textBox1_DoubleClick(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }





    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Team Leader
Iran (Islamic Republic of) Iran (Islamic Republic of)
Ghasem - Nobari
Qasem*AT*SQNco.com

Comments and Discussions