上传文件到SharePoint(WSS 3.0),使用HTTP PUT文档库 [英] Uploading files to Sharepoint (WSS 3.0) document library using HTTP PUT
本文介绍了上传文件到SharePoint(WSS 3.0),使用HTTP PUT文档库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有下面这段code的将文件上载到SharePoint。它使用HTTP PUT:
Hi I have the following piece of code to upload a file to Sharepoint. It uses HTTP PUT:
public static string UploadFile(string destUrl, string sourcePath)
{
try
{
Uri destUri = new Uri(destUrl);
FileStream inStream = File.OpenRead(sourcePath);
WebRequest req = WebRequest.Create(destUri);
req.Method = "PUT";
req.Headers.Add("Overwrite", "F");
req.Timeout = System.Threading.Timeout.Infinite;
req.Credentials = CredentialCache.DefaultCredentials;
Stream outStream = req.GetRequestStream();
string status = CopyStream(inStream, outStream);
if (status == "success")
{
outStream.Close();
WebResponse ores = req.GetResponse();
return "success";
}
else
{
return status;
}
}
catch (WebException we)
{
return we.Message;
}
catch (System.Exception ee)
{
return ee.Message;
}
}
当我运行这个code我得到异常:
When I run this code I get the exception:
远程服务器返回错误:(409)冲突。
"The remote server returned an error: (409) Conflict."
有没有人有任何想法,我要去的地方错了?
Does anyone have any ideas as to where I am going wrong?
谢谢,
亚历
推荐答案
我有,当我引用文档库的URL,而不是目标文件本身这个问题。
I've had this issue when I was referencing the url of the document library and not the destination file itself.
即。尝试的http://服务器名称 /文档库名称/新文件name.doc
i.e. try http://server name/document library name/new file name.doc
这篇关于上传文件到SharePoint(WSS 3.0),使用HTTP PUT文档库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文