Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.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
C# 使用visual studio 2010使用sharepoint 2010 web服务_C#_Visual Studio 2010_Sharepoint 2010 - Fatal编程技术网

C# 使用visual studio 2010使用sharepoint 2010 web服务

C# 使用visual studio 2010使用sharepoint 2010 web服务,c#,visual-studio-2010,sharepoint-2010,C#,Visual Studio 2010,Sharepoint 2010,我正在尝试通过Visual Studio 2010使用SharePoint 2010 web服务。我想下载文档库的所有文件,这些文件只能由经过身份验证的用户访问。我发现没有一个教程有效。有人能帮我吗?试试这个代码:请试试下面的函数。您需要传递FileURL(文档的完整web url)、Title(下载文件的传递名称) (注意:此功能需要为您要下载的文档传递凭据和完整url。我认为这对您来说已经足够了) 尝试此代码:请尝试下面的函数。您需要传递FileURL(文档的完整web url)、Title

我正在尝试通过Visual Studio 2010使用SharePoint 2010 web服务。我想下载文档库的所有文件,这些文件只能由经过身份验证的用户访问。我发现没有一个教程有效。有人能帮我吗?

试试这个代码:请试试下面的函数。您需要传递FileURL(文档的完整web url)、Title(下载文件的传递名称)

(注意:此功能需要为您要下载的文档传递凭据和完整url。我认为这对您来说已经足够了)


尝试此代码:请尝试下面的函数。您需要传递FileURL(文档的完整web url)、Title(下载文件的传递名称)

(注意:此功能需要为您要下载的文档传递凭据和完整url。我认为这对您来说已经足够了)


谢谢,如果我已经可以获得文档库中的文档列表,我将使用您的代码。我向copy.asmx服务添加了一个服务引用,但没有复制接口。仅CopySoap.use Web Reference添加此服务未添加到服务引用谢谢,如果我已经可以获取文档库中的文档列表,我将使用您的代码。我已将服务引用添加到copy.asmx服务,但没有复制接口。仅CopySoap.use Web引用添加此服务而不是添加到服务引用中
public string DownLoadfiletolocal(string FileURL, string Title)
{

//Copy.Copy is a webservice object that I consumed.

Copy.Copy CopyObj = new Copy.Copy();
CopyObj.Url = SiteURL + "/_vti_bin/copy.asmx"; // Dynamically passing SiteURL
NetworkCredential nc2 = new NetworkCredential();
nc2.Domain = string.Empty;
nc2.UserName = _UserName;
nc2.Password = _Password;


string copySource = FileURL; //Pass full url for document.

Copy.FieldInformation myFieldInfo = new Copy.FieldInformation();
Copy.FieldInformation[] myFieldInfoArray = { myFieldInfo };
byte[] myByteArray;

// Call the web service
uint myGetUint = CopyObj.GetItem(copySource, out myFieldInfoArray, out myByteArray);

// Convert into Base64 String
string base64String;
base64String = Convert.ToBase64String(myByteArray, 0, myByteArray.Length);

// Convert to binary array
byte[] binaryData = Convert.FromBase64String(base64String);

// Create a temporary file to write the text of the form to
string tempFileName = Path.GetTempPath() + "\\" + Title;

// Write the file to temp folder
FileStream fs = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite);
fs.Write(binaryData, 0, binaryData.Length);
fs.Close();

return tempFileName;

}