使用sharepoint下载文件时出现问题复制.asmx

2024-09-30 20:30:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用名为复制.asmx. 它的文件大小只有100 kb。在

但不是下载文件。在

web服务iteself在web服务响应中返回空流(out byte[]流)。这是内存问题吗。在

它还返回“download_document()out of memory”(下载文档()内存不足)

注意:我正在使用MFP打印机查看此应用程序。在


Tags: 文件of内存文档webkbdownloadbyte
1条回答
网友
1楼 · 发布于 2024-09-30 20:30:16

请尝试以下功能。您需要传递FileURL(文档的完整web url)、Title(要为下载的文件提供的pass name)

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;

}

相关问题 更多 >