【问题标题】:Upload document to specific folder in a SharePoint Document library using WebClient使用 WebClient 将文档上传到 SharePoint 文档库中的特定文件夹
【发布时间】:2010-09-23 16:35:24
【问题描述】:

我有一些客户端代码可以将 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/”。我可以发誓我曾尝试过,但又一次看起来我没有。

【问题讨论】:

  • 我犯了和你一模一样的错误……Durrrrr

标签: sharepoint document webclient document-library


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2016-12-06
    • 2010-10-02
    相关资源
    最近更新 更多