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
arvind chaubeyPosted Aug 12, 2009, 1:54 AM
FtpWebRequest reqFTP; try { //filePath = <
//file is to be created. the>>,
//fileName = <
//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);
}