URL下载器asp mvc

时间:2016-05-13 16:37:22

标签: asp.net-mvc

我正在用C#.net编写一个Windows应用程序来从互联网上下载文件

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        prbPercent.Value = e.ProgressPercentage;
        lblPercent.Text = e.ProgressPercentage.ToString();
    }

    private void Completed(object sender, AsyncCompletedEventArgs e)
    {
        MessageBox.Show("Completed");
    }

    private void btnPath_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog s = new FolderBrowserDialog();
        s.ShowDialog();
        txtPath.Text = s.SelectedPath;
    }

    private void btnDownload_Click(object sender, EventArgs e)
    {

        WebClient webClient = new WebClient();
        webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
        webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

        int t1 = txtLink.Text.LastIndexOf('/');
        string strFileName = txtLink.Text.Remove(0, t1 + 1);

        webClient.DownloadFileAsync(new Uri(txtLink.Text), txtPath.Text + "//" + strFileName);
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }
}

但是我正在寻找如何使用asp.net MVC编写类似的内容

我想用网站来做。

提前致谢。

0 个答案:

没有答案