代码之家  ›  专栏  ›  技术社区  ›  Kasper

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

  •  1
  • Kasper  · 技术社区  · 17 年前

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

    @"https://<server>/sites/<subweb>/<customer>/<teamweb>/<Documents>/" + docname;
    

    是此函数中的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;
        }
    

    但是我还没有弄清楚如何上传到一个现有的文件夹,即同一个文档库中的“电子邮件”。 甚至连谷歌都不知道答案:(-)

    注意:我知道我可以使用类似于SharePoint中的“复制Web服务”这样的工具将文件移动到其最终目标,但这更像是一种解决方法。


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

    对那个问题感到抱歉。igalse是对的,我只需要在URL中添加“emails/”。我可以发誓我已经试过了,但再次肯定我没有。

    1 回复  |  直到 17 年前
        1
  •  5
  •   Igal Serban    17 年前

    有了你的代码,我刚把/emails/添加到projecturl,上传就很好了。你试过了吗?也许你有权限问题。