我当前在我的Winforms应用程序中具有 awesomium webvcontrol。当我单击下载链接时,它将使用保存文件对话框提示。
我需要将文件下载到预设位置并自动打开。我正在使用最新版本的awesomium。
参考:
using Awesomium.Windows.Forms;
using Awesomium.Core;
有人想知道如何将控制点放在预设位置?
我设法解决了这一问题。我在WebCore的下载事件中添加了一种方法。
Awesomium.Core.WebCore.Download += onDownload;
该方法看起来像这样。
public static void onDownload(Object sender, DownloadEventArgs e)
{
e.Handled = true;
using (WebClient Client = new WebClient())
{
FileInfo file = new FileInfo("Your Path");
//replace Your Path with the path you wish to save the file including filename and extension
Client.DownloadFile(e.Url.ToString(), file.FullName);
//System.Windows.Forms.MessageBox.Show("Downloaded!");
Process.Start(file.FullName);
}
}
现在下载并打开文件。就我而言,这是.EXE应用程序。