Sharepoint WebService 采用 CopyIntoItems方式上传失败

aow11 2013-06-26 01:33:02
http://<Site>/_vti_bin/Copy.asmx

代码如下:
private bool Upload(string copyDest, string copySource)
{
bool bResult = false;
try
{
SPCopy.Copy rahulCopy = new SPCopy.Copy();
rahulCopy.Credentials = m_myCreCache;
rahulCopy.Url = m_sSite + "/" + "_vti_bin/" + "Copy.asmx";

SPCopy.FieldInformation FieldInformation = new SPCopy.FieldInformation();

SPCopy.FieldInformation[] fieldsInformation = { FieldInformation };
String[] destinationURLS = { copyDest };
FileStream fileStream = new FileStream(copySource, FileMode.Open, FileAccess.Read);
byte[] fileContent = new byte[fileStream.Length];
int length = (Int32)fileStream.Length;
fileStream.Read(fileContent, 0, length);
fileStream.Close();

SPCopy.CopyResult result1 = new SPCopy.CopyResult();
SPCopy.CopyResult result2 = new SPCopy.CopyResult();
SPCopy.CopyResult[] ResultCopy = { result1, result2 };

int outcome = (int)rahulCopy.CopyIntoItems(copyDest, destinationURLS, fieldsInformation, fileContent, out ResultCopy);//源文件和目标文件路径一样,Upload不覆盖已存在文件
if (outcome == 0)
{
bResult = true;
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
return bResult;
}


outcome 返回值是0,但是服务器站点没有上传的文件
是用的函数不对,还是代码写的不对,欢迎任何意见
...全文
157 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aow11 2013-06-27
  • 打赏
  • 举报
回复
问题描述不清楚? 没有人说话,眼看着沉下去
aow11 2013-06-26
  • 打赏
  • 举报
回复
除copySource是本地路径外,其他没差别,本地路径文件是存在的,上传的路径List也是存在的 把copySource置为一个同MSDN类似的站点上的文件路径,结果仍然是上传不成功
Justin-Liu 2013-06-26
  • 打赏
  • 举报
回复
路径对吗? 参考

3,242

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧