.NET的Sharepoint创建目录
-
20-08-2019 - |
题
我可以上传文件与Web客户端到SharePoint如下
using (System.Net.WebClient webclient = new System.Net.WebClient())
{
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(
Encryptor.Decrypt(ConfigurationManager.AppSettings["username"]),
Encryptor.Decrypt(ConfigurationManager.AppSettings["password"]),
ConfigurationManager.AppSettings["domain"]);
webclient.Credentials = credentials;
string path = Path.Combine("http://sharepoint.domain.com/dir", filename);
webclient.UploadData(path, "PUT", fileBytes);
}
但我不知道如何创建的目录,如果它们不存在。
任何想法,我该怎么办呢?
谢谢, -c
解决方案
在一个SharePoint站点的术语“目录”是欺骗性的。一个SharePoint web服务的“目录”结构是位于SharePoint数据库的虚拟结构。您需要确定哪些对象在SharePoint对象模型中的“目录”是例如: HTTP://sharepoint.domain .COM / DIR 可能是一个SPSite的,在该网站你可以有一个 '目录' 是SPFolders,SPLists,SPDocumentLibraries等。
所以,如果“创建目录不存在”您在SharePoint站点的目录结构的意思是,你将无法与Web客户端做的。你有两个选择:在Windows SharePoint Services的对象模型,和SharePoint Web服务。
在对象模型肯定是更容易在我看来使用,但它会要求你在同一台服务器上的SharePoint服务器上运行的应用程序。 web服务是一个多一点的工作,但它可以远程使用它们。
您将需要确定您要添加(例如SPFolder,SPSite的,SPList,SPDocumentLibrary等。)什么样的对象。
有充足的文档使用位于这里对象模型一>但如果你想使用的Web服务,您将需要在以下位置来访问它们:
Administration Service http://<server-url:port-number>/_vti_adm/admin.asmx
Alerts Service http://<server-url>/_vti_bin/alerts.asmx
Document Workspace Service http://<server-url>/_vti_bin/dws.asmx
Forms Service http://<server-url>/_vti_bin/forms.asmx
Imaging Service http://<server-url>/_vti_bin/imaging.asmx
List Data Retrieval Service http://<server-url>/_vti_bin/dspsts.asmx
Lists Service http://<server-url>/_vti_bin/lists.asmx
Meetings Service http://<server-url>/_vti_bin/meetings.asmx
Permissions Service http://<server-url>/_vti_bin/permissions.asmx
Site Data Service http://<server-url>/_vti_bin/sitedata.asmx
Site Service http://<server-url>/_vti_bin/sites.asmx
Users and Groups Service http://<server-url>/_vti_bin/usergroup.asmx
Versions Service http://<server-url>/_vti_bin/versions.asmx
Views Service http://<server-url>/_vti_bin/views.asmx
Web Part Pages Service http://<server-url>/_vti_bin/webpartpages.asmx
Webs Service http://<server-url>/_vti_bin/webs.asmx
我建议寻找到的词典或文档工作区服务的服务。
希望有所帮助。
不隶属于 StackOverflow