C# Awesomium Web 控件 - 自动下载和打开文件

C# Awesomium Web Control - automatically download and open files

我目前在我的 WinForms 应用程序中有一个 Awesomium Webvcontrol。当我单击下载 link 时,它会提示保存文件对话框。

我需要它把文件下载到预设位置并自动打开。我正在使用最新版本的 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 应用程序。