.net - Uploading a file to sharepoint using WebDav protocol and VB.NET -
i trying upload file sharepoint. authorization works fine, ends status ok
instead of created
. file not created. not understand why it's happening since used approach seems work others (no complaints). here's code using:
public sub create() dim szurl1 = "http://host.domain.com/p/projects/4/proposal/cze.txt" dim szcontent = string.format("date/time: {0} {1}", datetime.now.toshortdatestring(), datetime.now.tolongtimestring()) 'define username , password strings. dim domain = "domain_name" dim szusername = "user_name" dim szpassword = "password" dim httpputrequest httpwebrequest = directcast(webrequest.create(szurl1), httpwebrequest) httpputrequest.credentials = new networkcredential(szusername, szpassword, domain) httpputrequest.preauthenticate = true httpputrequest.method = "put" httpputrequest.headers.add("overwrite", "t") httpputrequest.contentlength = szcontent.length 'optional, allows larger files. httpputrequest.sendchunked = true dim requeststream = httpputrequest.getrequeststream() 'write string destination text file. requeststream.write(system.text.encoding.utf8.getbytes(directcast(szcontent, string)), 0, szcontent.length) 'close request stream. requeststream.close() 'retrieve response. dim httpputresponse httpwebresponse = directcast(httpputrequest.getresponse(), httpwebresponse) debug.writeline("put response #1: {0}", httpputresponse.statusdescription) end sub
this produces: put response #1: ok
, not put response #1: created
i took code from: http://blogs.iis.net/robert_mcmurray/archive/2010/02/09/sending-webdav-requests-in-net.aspx , translated vb, not think translation problem.
any ideas?
edit: checked original c# code , outcome same. problem?
having dealt in language suggest disabling sendchunked. 2 aren't supposed mixed , sharepoint 2010 doesn't seem uploading unknown sizes.
Comments
Post a Comment