【发布时间】:2011-11-25 03:52:49
【问题描述】:
我们开发了一个 WebPart 来读取 SiteCollection 中文档库中文件的内容。我使用以下代码读取内容。
WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultNetworkCredentials;
string documenturl = siteurl+"/" + file.Url.ToString();
content = wc.DownloadData(documenturl);//documenturl is the file path of the document
但是,我得到了以下错误 401 unathorized exception
System.Net.WebException: The remote server returned an error:(401) Unauthorized. at System.Net.WebClient.DownloadDataInternal(Uri address,WebRequest& request) at System.Net.WebClient.DownloadData(Uri address)
为了您的信息,我已经尝试通过 SPFile openBinary 方法下载文档。但它只适用于文档较小的情况。请参考以下网站。
getting ComException while reading the document in SharePoint 2010
提前致谢。
【问题讨论】:
标签: sharepoint-2010 comexception unauthorizedaccessexcepti