gpt4 book ai didi

sharepoint - .NET Sharepoint 创建目录

转载 作者:行者123 更新时间:2023-12-02 00:45:27 24 4
gpt4 key购买 nike

我可以按如下方式将文件上传到 webclient 的共享点

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 站点目录结构中,您将无法使用 WebClient。您有两个选择:Windows SharePoint Services 对象模型和 SharePoint Web 服务。

在我看来,对象模型当然更易于使用,但它需要您在与 SharePoint 服务器相同的服务器上运行该应用程序。 Web 服务需要更多工作,但它使您能够远程使用它们。

您需要确定要添加的对象类型(例如 SPFolder、SPSite、SPList、SPDocumentLibrary 等)。

关于使用对象模型的大量文档位于 Here但如果您想使用网络服务,则需要在以下位置访问它们:

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

我建议查看列表或文档工作区服务服务。

希望对您有所帮助。

关于sharepoint - .NET Sharepoint 创建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/840767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com