Create file on ftp server using FtpwebRequest C# -
ftpuploadstring("newdatsa", ftp + "sale.txt", username, password); private void ftpuploadstring(string text, string to_uri, string user_name, string password) { // object used communicate server. ftpwebrequest request = (ftpwebrequest)webrequest.create(to_uri); request.method = webrequestmethods.ftp.uploadfile; // network credentials. request.credentials = new networkcredential(user_name, password); // write text's bytes request stream. request.contentlength = text.length; using (stream request_stream = request.getrequeststream()) { byte[] bytes = encoding.utf8.getbytes(text); request_stream.write(bytes, 0, text.length); request_stream.close(); } }
i trying create file of ftp server .the above mention method works when "sale.txt" file exist on server .i need create file on sever , write via ftpwebrequest or other method.kinldy guid me this.thanks
Comments
Post a Comment