Uploading a text box into a text file on an ftp C# -
Can I tell a multilingual text box to stream into a text file on an FTP server? Can anyone tell me Is that where I'm going wrong?
  Private Zero btnSave_Click (Object Sender, EventArgs e) {UriBuilder b = new UriBuilder (); B.Host = "ftp.myserver.com"; B.UserName = "User"; B Password = "pass"; B Port = 21; B.path = "/myserver.com/directories/" + selected + ".txt"; B.Scheme = Uri.UriSchemeFtp; Uri G = B Yuri; System.Net.FtpWebRequest c = (System.Net.FtpWebRequest) System.Net.FtpWebRequest.Create (G); C.Method = System.Net.WebRequestMethods.Ftp.DownloadFile; System.Net.FtpWebResponse d = (System.Net.FtpWebResponse) c.GetResponse (); System Io Stream H = D. Gateresonsstream; System.IO.StreamWriter SW = New System. IO.StreamWriter (h); String [] content = textbox1 Lines Toure (); (Int i = 0; I & lt; Content height; i ++) {SW.WriteLine (content [i]); } H. Close (); SW.Close (); D.Close (); }   The error I am getting is this line:
System.io.stream water SW = new system.io.stream water (h);
The stream was not writable.
Any thoughts?
  Feedback from FTP site  stream data  to  You need the  request  stream from the site  to  ... but then you will not want any method of  DownloadFile  - you are not downloading , You are uploading, so you want  UploadFile  method. 
Additionally:
-  Exceptions are thrown when you are not closing anything: Use 
by usingfor it Block - This is a bad idea to access such a network on the UI thread; UI threads will be blocked (hence the entire UI will hang) while FTP requests are being requested. Use a background thread instead.
 
Comments
Post a Comment