954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

download two Youtube videos together help

Hi guys need urgent help.
I am making a youtube downloader that downloads two or more videos from Youtube at the same time and I don't how to do it using System.Net.Webclient in C#.Net.

Please post a code snippet. HELP!

earlybirdsean
Newbie Poster
17 posts since Jul 2011
Reputation Points: 4
Solved Threads: 0
 

Just thought I'd let you know that no one is going to just give you all the code for this. You need to try this stuff out on your own, then when you get stuck on a specific part, ask questions about that specific part.

If you'd like, post the code you have so far (not everything, just the parts that are important) and point out the part that isn't working and the error messages you get.

You will get much more help here if you show that you are doing work yourself and not just asking the community to do your job for you.

stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

OK.Here's the part of the code.

try
        {
            wc = new WebClient();
            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
            wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
            lnkCancel.Enabled = true;
            wc.DownloadFileAsync(new Uri(link), dwnFile);
            lblResult.Visible = false;
        }
        catch (Exception)
        {
            MessageBox.Show("  Unexpected error occured.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            try { File.Delete(dwnFile); if (_audio) File.Delete(filePath); }
            catch (Exception) { }
            unlockGui();
        }
        lblResult1.Text = "";

And here's the code for the DownloadFileCompleted

void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
    {
        lnkCancel.Enabled = false;

        if (e.Cancelled)
        {
            MessageBox.Show("Download canceled.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            try
            {
                File.Delete(dwnFile);
                if (_audio) File.Delete(filePath);
            }
            catch (Exception) { }
            unlockGui();
            return;
        }
        wc = null;
        try
        {
            FileInfo f = new FileInfo(dwnFile);
            if (f.Length < 4)
            {
                MessageBox.Show("  Error occured during download.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                f = null;
                try
                {
                    if (_audio) File.Delete(filePath); File.Delete(dwnFile);
                }
                catch (Exception) { }
            }
            else
            {
                f = null;
                progressBar1.Value = 0;
                if (_audio)
                {
                    toMp3(dwnFile);
                    try { File.Delete(dwnFile); }
                    catch (Exception) { }
                }
                this.Activate();
            }
        }
        catch (Exception ex)
        {
            this.Activate();
            MessageBox.Show("Error: " + ex.Message, Application.ProductName);
        }
        unlockGui();
        lblResult.Text = "Done ";
    }

Please help me. Hope this is enough.

earlybirdsean
Newbie Poster
17 posts since Jul 2011
Reputation Points: 4
Solved Threads: 0
 

OK.Here's the part of the code.

try
        {
            wc = new WebClient();
            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
            wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
            lnkCancel.Enabled = true;
            wc.DownloadFileAsync(new Uri(link), dwnFile);
            lblResult.Visible = false;
        }
        catch (Exception)
        {
            MessageBox.Show("  Unexpected error occured.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            try { File.Delete(dwnFile); if (_audio) File.Delete(filePath); }
            catch (Exception) { }
            unlockGui();
        }
        lblResult1.Text = "";

And here's the code for the DownloadFileCompleted

void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
    {
        lnkCancel.Enabled = false;

        if (e.Cancelled)
        {
            MessageBox.Show("Download canceled.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            try
            {
                File.Delete(dwnFile);
                if (_audio) File.Delete(filePath);
            }
            catch (Exception) { }
            unlockGui();
            return;
        }
        wc = null;
        try
        {
            FileInfo f = new FileInfo(dwnFile);
            if (f.Length < 4)
            {
                MessageBox.Show("  Error occured during download.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                f = null;
                try
                {
                    if (_audio) File.Delete(filePath); File.Delete(dwnFile);
                }
                catch (Exception) { }
            }
            else
            {
                f = null;
                progressBar1.Value = 0;
                if (_audio)
                {
                    toMp3(dwnFile);
                    try { File.Delete(dwnFile); }
                    catch (Exception) { }
                }
                this.Activate();
            }
        }
        catch (Exception ex)
        {
            this.Activate();
            MessageBox.Show("Error: " + ex.Message, Application.ProductName);
        }
        unlockGui();
        lblResult.Text = "Done ";
    }

Please help me. Hope this is enough.

earlybirdsean
Newbie Poster
17 posts since Jul 2011
Reputation Points: 4
Solved Threads: 0
 

Is there an error message you are getting?

stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

yes..like that ERROR:Download file argument

earlybirdsean
Newbie Poster
17 posts since Jul 2011
Reputation Points: 4
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: