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,但是服务器站点没有上传的文件
是用的函数不对,还是代码写的不对,欢迎任何意见