'Install A folder from the web into a directory with C#

I am trying to make an installer app for an aircraft for X-Plane 11. I need to find a way to get a folder and install it to a user defined directory. How do i do this? Here is what i've tried: To get the users directory from the textbox after the save button is clicked:

        private void SavePathButton_Click(object sender, RoutedEventArgs e)
        {
            DownloadPath = SavePathTextbox.Text;
            SavePathTextbox.Text = $"{DownloadPath}";
            MessageBox.Show("Folder path saved!");
        }
    
    private void InstallButton_Click(object sender, RoutedEventArgs e)
        {
            if (DownloadPath == "")
            {
                MessageBox.Show("Please input your mod folder path before installing. If you have already done this, remember to click save before installing.");
            }
            else
            {
                string installURL = "https://github.com/lovelygentleman/Test-Repo/archive/refs/tags/t.zip";
                string savePath = $"{DownloadPath}";
                WebClient installWebClient = new WebClient();
                installWebClient.DownloadFile(installURL, savePath);
            }


Solution 1:[1]

In order to get a file path from the user you'll need to prompt a SaveFileDialog (you'll need to add using Microsoft.Win32).

Your code would become something like this

private void InstallButton_Click(object sender, RoutedEventArgs e)
{
    if (DownloadPath == "")
    {
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        if(saveFileDialog.ShowDialog())
            DownloadPath = saveFileDialog.FileName; 
        else
            //The user cancelled the dialog. Do whatever you need           
    }
    else
    {
        string installURL = "https://github.com/lovelygentleman/Test-Repo/archive/refs/tags/t.zip";
        string savePath = $"{DownloadPath}";
        WebClient installWebClient = new WebClient();
        installWebClient.DownloadFile(installURL, savePath);
    }
}

More info here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1