Welcome Guest Search | Active Topics | Sign In | Register

Download on the background Options
AiSatan
Posted: Saturday, July 16, 2016 5:16:07 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
I want to use specific methods before file starting download. But BeforeDownloadEvent not work for me because it's not suspend download and while I use my methods, file has been downloaded, and it's broke my code.
I found this post, and it's sad for me.
Can you help me with this issue?
I can cancel download item, but can't resume, any solution?
eo_support
Posted: Sunday, July 17, 2016 9:39:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

No. Currently you can not pause the download. You either cancel it all together or let it continue until finish.

Thanks!
serializer
Posted: Sunday, July 17, 2016 2:55:57 PM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 84
Hi, I am interested in this as well and currently it is not normal browser behavior and can cause strange problems when download sites redirect to thank you page. It must be some programatic solution to this. At least hang the download thread some way?
AiSatan
Posted: Monday, July 25, 2016 6:50:00 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
I tested with latest build (16.1.54) with pause and resume methods and I can't set a download path.
I used to set the path BeforeDownload event and BeforeDownloadEventArgs.FullPath property, now it's not work, it's a bug, or I must to do something else?
eo_support
Posted: Monday, July 25, 2016 10:39:11 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

We have confirmed this to be a bug. We will fix it and post an update build this week.

Thanks!
eo_support
Posted: Friday, August 5, 2016 11:53:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

This is just to let you know that we have posted a new build that should fix the FullPath issue. You can download the new build from our download page.

Thanks!
AiSatan
Posted: Friday, August 5, 2016 12:12:01 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
It's work fine, thanks!
eo_support
Posted: Friday, August 5, 2016 4:53:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Great. Thanks for confirming the fix!
AiSatan
Posted: Monday, August 8, 2016 7:35:13 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
Hi again, I still have a problems with download.

the code doesn't work and file didn't download to the folder:

Code: C#
private void Form1_Load(object sender, EventArgs e)
		{
			webControl1.WebView.DownloadUpdated += WebViewOnDownloadUpdated;
			webControl1.WebView.BeforeDownload +=WebViewOnBeforeDownload;
		}

		private void WebViewOnBeforeDownload(object sender, BeforeDownloadEventArgs beforeDownloadEventArgs)
		{
			beforeDownloadEventArgs.Item.Pause();
			Console.WriteLine("before");
			beforeDownloadEventArgs.ShowDialog = false;
			beforeDownloadEventArgs.FilePath = @"C:\Users\AiSatan\Downloads\test.exe";
			beforeDownloadEventArgs.Item.Resume();
		}

		private void WebViewOnDownloadUpdated(object sender, DownloadEventArgs downloadEventArgs)
		{
			Console.WriteLine("update");
		}

//Output:
//
//before
//update


As you can see, update event fires only once (I think after Pause or Resume methods)
If I use only this:

Code: C#
private void Form1_Load(object sender, EventArgs e)
		{
			webControl1.WebView.DownloadUpdated += WebViewOnDownloadUpdated;
			webControl1.WebView.BeforeDownload +=WebViewOnBeforeDownload;
		}

		private void WebViewOnBeforeDownload(object sender, BeforeDownloadEventArgs beforeDownloadEventArgs)
		{
			Console.WriteLine("before");
			beforeDownloadEventArgs.ShowDialog = false;
			beforeDownloadEventArgs.FilePath = @"C:\Users\AiSatan\Downloads\test.exe";
		}

		private void WebViewOnDownloadUpdated(object sender, DownloadEventArgs downloadEventArgs)
		{
			Console.WriteLine("update");
		}

//Output:
//
//before


file downloaded correct, but DownloadUpdated never called.


eo_support
Posted: Monday, August 8, 2016 12:12:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Not all downloads trigger DownloadUpdated event. When the download starts, the web server can send down the total size of the file to be downloaded or not. If it does send total size of the file, then the browser engine will be able to calculate the progress based on the number of bytes it has received. When this is the case, DownloadUpdated is called. If the server does not send the total size of the file, then the browser engine can not calculate the progress thus it does not trigger DownloadUpdated event.

You can test the event with our own TabbedBrowser sample change the code in WebView_BeforeDownload from:

Code: C#
e.ShowDialog = true;


To:

Code: C#
e.ShowDialog = false;
e.FilePath = your_file_path;


You can then use it to download the file from our download page and you should be able to see the download progress get correctly updated.

Thanks!
AiSatan
Posted: Monday, August 8, 2016 12:27:45 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
Ok, I will look the sample proj. But why the file still download to temp folder if I use the new methods?

Code: C#
private void Form1_Load(object sender, EventArgs e)
		{
			webControl1.WebView.DownloadUpdated += WebViewOnDownloadUpdated;
			webControl1.WebView.DownloadCompleted += WebViewOnDownloadCompleted;
			webControl1.WebView.BeforeDownload += WebViewOnBeforeDownload;
		}

		private void WebViewOnDownloadCompleted(object sender, DownloadEventArgs downloadEventArgs)
		{
			Console.WriteLine("path: {0}", downloadEventArgs.Item.FullPath);
		}

		private void WebViewOnBeforeDownload(object sender, BeforeDownloadEventArgs beforeDownloadEventArgs)
		{
			beforeDownloadEventArgs.Item.Pause();
			Console.WriteLine("before");
			beforeDownloadEventArgs.ShowDialog = false;
			beforeDownloadEventArgs.FilePath = @"C:\Users\AiSatan\Downloads\test.exe";
			beforeDownloadEventArgs.Item.Resume();
		}

		private void WebViewOnDownloadUpdated(object sender, DownloadEventArgs downloadEventArgs)
		{
			Console.WriteLine("update");
		}

//Output:

//before
//update
//path: C:\Users\AiSatan\AppData\Local\Temp\calc.exe



In your tabbrowser sample too
eo_support
Posted: Monday, August 8, 2016 12:38:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Do not call Pause/Resume in your BeforeDownload handler. Just set ShowDialog and set FilePath and you should be all fine.

Thanks!
AiSatan
Posted: Monday, August 8, 2016 12:42:35 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
and.. where I must to use the methods?
just I want to pause download before it start any downloads to my temp folder.
serializer
Posted: Monday, August 8, 2016 1:05:43 PM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 84
There seems to be a misunderstanding here. Here is what we are trying to achieve;

1. we click on a link
2. now it auto-downloads in temp folder - this is not what we want. We want to open our own dialog and set the download location - then start download

How do you mean we can set download path when it auto-starts downloading to the wrong path?
eo_support
Posted: Monday, August 8, 2016 1:45:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

You are thinking too much about "now it auto-downloads in temp folder - this is not what we want". The download will always start to a temp folder. The difference is when the download is done, where it moves that temp file to.

If you just want to change the "Save As" dialog, you do not need to handle BeforeDownload event at all. You can just handle FileDialog event and show your own dialog in that event handler.

Thanks!
serializer
Posted: Tuesday, August 9, 2016 4:08:30 PM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 84
Thanks, it works as expected now.
eo_support
Posted: Tuesday, August 9, 2016 4:21:25 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Great. Glad to hear that! Please feel free to let us know if you have any more questions.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.