Skip to content

Implementing FTP Append function in .net 1.1

veeru s

Asked Aug 6, 2009, 2:30 PM EDT1 answer
Share
LinkedInX
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.

  • 0
    Code
    Try using this code:
    Code
    Java
    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);
        }
    Code
    I think this will help u .
    Code
    Thanks,
    Code
    Arvind Kumar Chaubey
    Code
    "Plz Mark Answer if this post help you"
    0