Windows Forms: Youtube Downloader in C#

How to make a Youtube Downloader using Video Library in C#. libvideo is a fast, clean way to download YouTube videos, It's fully portable and has no dependencies

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "CSYoutube" and then click OK

youtube download in c#Step 2: Right click on your project select Manage NuGet Packages -> Search libvideo -> Install

install libvideoStep 3: Design youtube download form as below

youtube download in c#

Step 4: Add code to handle download file

using System;
using System.IO;
using System.Windows.Forms;
using VideoLibrary;

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

        //Async download file
        private async void btnDownload_Click(object sender, EventArgs e)
        {
            using(FolderBrowserDialog fbd = new FolderBrowserDialog() { Description="Select your path." })
            {
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    var youtube = YouTube.Default;
                    lblStatus.Text = "Downloading...";
                    //Download file
                    var video = await youtube.GetVideoAsync(txtUrl.Text);
                    File.WriteAllBytes(fbd.SelectedPath + video.FullName, await video.GetBytesAsync());
                    lblStatus.Text = "Completed !";
                }
            }

        }
    }
}

VIDEO TUTORIALS