来自C#客户端的文件上传问题 [英] File Upload issue from C# Client
问题描述
亲爱的
我是这个论坛的新手,因此对任何错误深表歉意.
I am new to this forum - hence advance apologies for any mistakes.
我被授予对客户端的Sharepoint Office 365网站的受限访问权限-我必须编写C#客户端才能将文件上传到客户端在运行时指定的目录. 客户端创建了一个测试目录,并只授予我对该目录的访问权限.
I have been given restricted access to a client's Sharepoint Office 365 site - I have to write a C# client to upload files to a directory that the client will specify at runtime. Client created a test directory and gave me access only to that directory.
结构如下-
网站: https://XXXX.sharepoint.emea.microsoftonline.com/Shared%20Documents/BLAH
浏览网络,我创建了以下代码-
using (Microsoft.SharePoint.Client.ClientContext clientContext = new ClientContext(website))
{
System.Security.SecureString passWord = new System.Security.SecureString();
foreach (char c in password.ToCharArray())
{
passWord.AppendChar(c);
}
clientContext.Credentials = new SharePointOnlineCredentials(username, passWord);
Web web = clientContext.Web;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(filewithpath);
newFile.Url = Path.GetFileName(filewithpath);
List docs = web.Lists.GetByTitle(path);
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
clientContext.ExecuteQuery();
}
}
当我运行代码时,它在一行上阻塞-clientContext.ExecuteQuery(); 出现以下错误-
When I run the code it chokes on the line - clientContext.ExecuteQuery(); with the following error -
身份客户端运行时库(IDCRL)与伙伴STS通话时遇到错误."
"Identity Client Runtime Library (IDCRL) encountered an error while talking to the partner STS."
由于我对共享点不太熟悉,因此我感到自己可能发送了错误的参数. 鉴于我拥有的网站结构,以下参数的价值是什么? -
I have a bad feeling that I might be sending wrong parameters since I am not familiar with sharepoint that much. Given the website structure I have, what would be the values of the following params? -
1.新ClientContext(网站)中的网站
1. website in the new ClientContext(website)
2. web.Lists.GetByTitle(path)中的路径
2. path in the web.Lists.GetByTitle(path)
3.在我的情况下,docs.RootFolder的值是多少? 是"/BLAH"吗?
3. What would be the value of docs.RootFolder in my case? Is it "/BLAH"?
什么是共享点中的库和列表?
What are Library and List exactly in sharepoint?
很抱歉为您发表冗长的帖子!真诚的歉意!
So sorry for the long post! Sincere apologies!
请帮助!
感谢和问候!
赖汉
推荐答案
您好,Raihan,
Hi Raihan,
请尝试以下提到的步骤,并检查问题是否得到解决:-
Try steps mentioned below and check whether issue get resolved : -
-
卸载了SharePoint Online命令行管理程序( http://www.microsoft.com/zh-cn/download/details.aspx?id = 35588 ).原始程序是在去年秋天编写并启动的 作为PowerShell程序的扩展,使用了SharePoint Online命令行管理程序附带的Microsoft.Online.SharePoint.Client.Tenant.dll.该程序应引用C:\ Program Files \ SharePoint客户端组件\ 16.0 \ Assemblies \ Microsoft.Online.SharePoint.Client.Tenant.dll.
-
Uninstalled the SharePoint Online Management Shell (http://www.microsoft.com/en-us/download/details.aspx?id=35588). The original program, which was written last fall and started as an extension of a PowerShell program, used the Microsoft.Online.SharePoint.Client.Tenant.dll that came with the SharePoint Online Management Shell. The program should reference C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll.
安装了最新的SharePoint Online客户端组件SDK( http://www.microsoft.com. com/en-us/download/details.aspx?id = 42038 ).请务必注意,此SDK与 SharePoint 2013客户端组件SDK. SharePoint Online客户端组件SDK为版本16;的SharePoint 2013客户端组件SDK为版本15.
Installed the latest SharePoint Online Client Components SDK (http://www.microsoft.com/en-us/download/details.aspx?id=42038). It is important to note that this SDK is different that the SharePoint 2013 Client Components SDK. The SharePoint Online Client Components SDK is version 16; the SharePoint 2013 Client Components SDK is version 15.
确保从Web Server Extensions文件夹中的16版本加载的程序中的Microsoft.SharePoint.Client和Microsoft.SharePoint.Client.Runtime dll,例如C:\ Program Files \ Common Files \ Microsoft共享\ Web服务器扩展\ 16 \ ISAPI \ Microsoft.SharePoint.Client.dll.
Ensured that the Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime dlls in the program loaded from the 16 version in the Web Server Extensions folder, e.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll.
此致
Gaurav Shende
Gaurav Shende
如果有帮助,请标记为答案...
这篇关于来自C#客户端的文件上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!