Question Webbrowser download without prompt

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I created a webbrowser in a tab. I want to download files to the default directory without the save prompt.
webbroser:
            Dim imgBrowser As New WebBrowser
            With imgBrowser
                AddHandler .DocumentCompleted, AddressOf imgBrowser_DocumentCompleted
                AddHandler .NewWindow, AddressOf imgBrowser_NewWindow 'prevent new window from opening

                 .Size = New Size(tpBrowser.Width, tpBrowser.Height)
                .Location = New Point(0, 0)
                .Name = title

                .ScriptErrorsSuppressed = True
                .Navigate(url)

                tpBrowser.Controls.Add(imgBrowser)
            End With
 
No. Your question sounded like you were performing the download in code, rather than initiated by the user. You probably ought to be using a WebView2 rather than a WebBrowser.
 
i use the webbrowser to open to a URL with different links. I would click on one of them to do a download.
 
If this helps, this is how I recursively download multiple files (as many as you want if you keep adding "For Each" statements) in C#.
You can convert the code below at the online free converter, it gives you so much uses in a day. It's the best free one you'll find, however, Visual Studios comes with tools you can download to address that as well. In this example, I'm downloading files from OpenDrive.com

using System;
using System.Diagnostics;
using System.Net;
using System.Reflection.Emit;
using System.Windows.Forms;

namespace URL_HOST_REQUEST
{

public partial class Form1 : Form
{


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();

DownloadStart();
}

private WebClient downloader;

public string Description { get; private set; }

public void DownloadStart()
{

for (int i = 0; i < 10; i++)
{
string url = "https://od.lk/d/MTRfMjYwNzk4Mjlf/horrormovie2.wav";

progressBar1.Visible = true;

downloader = new WebClient();

downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;

downloader.DownloadFileAsync(new Uri(url), Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\horrormovie2.wav");
}

for (int i = 0; i < 10; i++)
{
string url = "https://od.lk/d/MTRfMjYwNzk4MTBf/FastWhooshSFX.wav";

progressBar1.Visible = true;

downloader = new WebClient();

downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;

downloader.DownloadFileAsync(new Uri(url), Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\FastWhooshSFX.wav");
}
}

private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Debug.WriteLine(e.ProgressPercentage);
}

private void Timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);

label1.Text = progressBar1.Value + "% Downloading From Host...";


if (progressBar1.Value >= 100)
{
progressBar1.Value = progressBar1.Value;

timer1.Stop();

Application.Exit();
}

}

}


}
 
Back
Top