[英]How download an Excel File from SharePoint using WinForm app
我在SharePoint中具有以下路径:
我需要使用在VS 2013,Framework .Net 4.0中创建的WinForm应用程序将该文件下载并存储在我的个人计算机中。
是否存在一些仅通过直接链接实现此目标的方法?
如果要异步下载,请使用以下命令:
private void buttonDownload_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadFileProgressChanged);
webClient.DownloadFileAsync(new Uri("http://example.com/myfile.xlsx"), @"c:\myfile.xlsx");
}
private void DownloadFileProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
// Update the progress bar component
progressBar.Value = e.ProgressPercentage;
}
private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Download completed!");
}
using System.Net;
WebClient webClient = new WebClient();
webClient.DownloadFile("http://example.com/myfile.txt", @"c:\myfile.txt");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.