c# - Cannot send a content-body with this verb-type -
ftpwebrequest request = (ftpwebrequest)webrequest.create("ftp://www.mysite.com/public_html/text.txt"); request.method = webrequestmethods.ftp.downloadfile; request.credentials = new networkcredential(" ", " "); streamreader sourcestream = new streamreader(environment.currentdirectory + "/text.txt"); byte[] filecontents = encoding.utf8.getbytes(sourcestream.readtoend()); sourcestream.close(); request.contentlength = filecontents.length; stream requeststream = request.getrequeststream(); requeststream.write(filecontents, 0, filecontents.length); requeststream.close(); ftpwebresponse response = (ftpwebresponse)request.getresponse(); response.close();
stream requeststream = request.getrequeststream(); giving me error "cannot send content-body verb-type.".
any on how fix great.
you have told use downloadfile, ftp retr method - , not take body - in same way http not take body. specify uploadfile (ftp stor) or similar if want send body; or - don't send body.
Comments
Post a Comment