使用WebClient将文档上载到SharePoint文档库中的特定文件夹

Kas*_*per 1 sharepoint document webclient document-library

我有一些客户端代码将Outlook电子邮件上传到文档库,只要路径指向文档库的根,它就可以正常工作.

@"https://<server>/sites/<subweb>/<customer>/<teamweb>/<Documents>/" + docname;
Run Code Online (Sandbox Code Playgroud)

是这个函数中的projectUrl:

public bool SaveMail(string filepath, string projectUrl)
    {
        try
        {
            using (WebClient webclient = new WebClient())
            {
                webclient.UseDefaultCredentials = true;
                webclient.UploadFile(projectUrl, "PUT", filepath);
            }
        }
        catch(Exception ex)
        {
            //TO DO Write the exception to the log file
            return false;
        }
        return true;
    }
Run Code Online (Sandbox Code Playgroud)

但是我无法弄清楚如何上传到现有文件夹,即同一文档库中的"电子邮件".甚至谷歌似乎都不知道答案:-)

注意:我知道我可以使用SharePoint中的复制Web服务将文件移动到其最终目的地,但这更像是一种解决方法.


我什么时候才能学会不工作到深夜:-(

抱歉,这个问题.Igalse是对的,我只需要在URL中添加"emailils /".我可以发誓我已经尝试过了,但是再一次看起来我确实没有.

Iga*_*ban 5

使用您的代码我刚刚将/ Emails /添加到projectUrl,上传工作正常.你试过吗?也许你有权限问题.