Implementing FTP Append function in .net 1.1
Hi,
I need to append a text file from my application to remote server using FTP Append , can any one please let me know how can implement in .net 1.1 framework. Can i do the same functionality using any other communication technique.
Max file size will be 10 MB
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
arvind chaubey4 pointsPosted Aug 11, 2009, 9:54 PM EDT
FtpWebRequest reqFTP; try { //filePath = <<The full path where the //file is to be created. the>>, //fileName = <<Name of the file to be createdNeed not //name on FTP server. name name()>> FileStream outputStream = new FileStream(filePath + "\\" + fileName, FileMode.Create); reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + fileName)); reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); Stream ftpStream = response.GetResponseStream(); long cl = response.ContentLength; int bufferSize = 2048; int readCount; byte[] buffer = new byte; readCount = ftpStream.Read(buffer, 0, bufferSize); while (readCount > 0) { outputStream.Write(buffer, 0, readCount); readCount = ftpStream.Read(buffer, 0, bufferSize); } ftpStream.Close(); outputStream.Close(); response.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); }