I have some code I inherited that is trying to copy files to a 
sharepoint location. It is working for most of my files, but for 
some it fails on the stream.close method. The error message is "The 
remote server returned an error: (409) Conflict." Anyone have any 
experience with this? Here's my code. Any suggestions that could 
replace this method or improvements?

private bool AddSPFiles(string strDocURI , string strSrcFile,string 
strDocType)
{
try
{

System.Net.WebClient oClient = new WebClient();

//create oIdent so we can impersonate generic account for share 
access & sharepoint access
string strUserID = ProfileBroker.GetValue("generic-user-name");
string strDomain = ProfileBroker.GetValue("generic-user-domain");
string strPassword = ProfileBroker.GetValue("generic-user-password");

System.Net.NetworkCredential oIdent = new 
System.Net.NetworkCredential(strUserID,strPassword,strDomain);
                                        
oClient.Credentials =oIdent;
oClient.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
oClient.Headers.Add("charset:UTF-8");
oClient.Headers.Add("user-agent: Mozilla/2.0 (compatible; MSIE 
3.0B;Windows NT)");

FileStream oFileStream = File.OpenRead(strSrcFile);
BinaryReader oReader = new BinaryReader(oFileStream);
Byte[] postArray    =  oReader.ReadBytes(Convert.ToInt32
(oFileStream.Length));

Stream oPostStream  = oClient.OpenWrite(strDocURI,"PUT");
oPostStream.Write(postArray, 0, postArray.Length);
oPostStream.Close(); //This line is where I get the error
oReader.Close();
oFileStream.Close();
return true;

}
catch(Exception ex)
{
  throw new Exception(" Could Not Add File To Share Point Folder " + 
ex.Message);
};
}

Thanks,
Jim





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to