Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint C#-如何从GetFileByServerRelativeUrl下载文件_C#_Sharepoint - Fatal编程技术网

Sharepoint C#-如何从GetFileByServerRelativeUrl下载文件

Sharepoint C#-如何从GetFileByServerRelativeUrl下载文件,c#,sharepoint,C#,Sharepoint,在Google的前几页上,我已经尝试了几乎所有推荐的代码示例和技术。所有这些示例都失败,但出现超时或类似错误 static void Main(string[] args) { using (WebClient client = new WebClient { Credentials = new NetworkCredential("username", "password", "domain") }) { var tmp

在Google的前几页上,我已经尝试了几乎所有推荐的代码示例和技术。所有这些示例都失败,但出现超时或类似错误

    static void Main(string[] args)
    {

        using (WebClient client = new WebClient { Credentials = new NetworkCredential("username", "password", "domain") })
        {
            var tmpFile = Path.GetTempFileName();
            String url = "https://sharepoint.organisation.net/GetFileByServerRelativeUrl/folder/file.docx')/$value')/Files";
            client.DownloadFile(new Uri(url), tmpFile);

            //OR 

            //              client.DownloadFileAsync(new Uri(url), tmpFile);
        }
    }
如果有人能给我一个建议,说明为什么我的代码,不管使用何种下载方法,都会在实际请求时超时,那就太好了


此方法用于测试sharepoint上的文件分析。

这不是有效的url,并且没有
GetServerByRelativeUrl
函数。我想你想要的是
https://sharepoint.organisation.net/_api/web/folders/getbyserverrelativeurl('folder')/files/getbyname('file.docx')/$value
很抱歉,我实际使用的方法是GetFileByServerRelativeUrlAnd,否则URL会起作用,但是被截断以避免泄露内部网络的信息#操作安全文件数据来自
$value
端点。如果实际的URL格式正确(与您的问题不同),那么它将通过在
$value
处结束URL来工作。当通过python脚本调用和验证时,完整的URL工作。或通过经过身份验证的浏览器会话直接访问。