使用WebClient将文档上传到SharePoint文档库中的特定文件夹 [英] Upload document to specific folder in a SharePoint Document library using WebClient

查看:198
本文介绍了使用WebClient将文档上传到SharePoint文档库中的特定文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have some client side code that uploads an Outlook email to a document library and as long as the path is pointing to the root of the doc library it works just fine.

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

是此函数中的projectUrl:

is the projectUrl in this function :

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;
    }

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

but I have not been able to figur out how to upload to an existing folder i.e. "Emails" in the same document library. Not even Google seems to know the answer :-)

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

Note: I know that I could use something like the Copy web service within SharePoint to move the file to its final destination, but that is more like a workaround.

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

When will I learn not to work that late into the night :-(

很抱歉这个问题. Igalse是正确的,我只需要在URL中添加"emails/".我可以发誓我曾经尝试过,但是再一次肯定看起来好像我没有.

Sorry about that question. Igalse is right, I just needed to add "emails/" to the URL. I could swear that I had tried that, but then again it sure looks like I didn't.

推荐答案

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

With your code I just added /Emails/ to the projectUrl and the upload worked just fine. Have you tried that? Maybe you have permission problem.

这篇关于使用WebClient将文档上传到SharePoint文档库中的特定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆