繁体   English   中英

如何使用WinForm应用程序从SharePoint下载Excel文件

[英]How download an Excel File from SharePoint using WinForm app

我在SharePoint中具有以下路径:

http://xxxx.xxx.com/bu/PSCLA/Document_3/LA%20Sites/Rio/Site%20OP%20Strategy/Master%20Data%20Audit%20Hair%20Care%20Rio%20Plant/MRP%201-4%20and% 20WS%20POSS.xlsx

我需要使用在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!");
}

使用WebClient.DownloadFile

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM