I found out the answer atlast it will works
public
bool UploadFile(string file_to_upload,int attempts)
{
if (System.IO.File.Exists(file_to_upload))
{
//FtpWebResponse response;
int Appendinglength = 0;
int TotalLength = 0;
pointer = 1;
long FTPFilesize = 0;
while (--attempts >= 0)
{
try
{
FileInfo finfo = new FileInfo(file_to_upload);
TotalLength =
Convert.ToInt32(finfo.Length);
FtpWebRequest ftprequest;
ftprequest = (
FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + IP + "/" + finfo.Name));
ftprequest.Credentials =
new NetworkCredential(Uname, Pwd);
ftprequest.UseBinary =
true;
ftprequest.KeepAlive =
false;
if (ISFtpFileExists(finfo.Name, out FTPFilesize))
{
ftprequest.Method =
WebRequestMethods.Ftp.AppendFile;
//ftprequest.ContentLength = finfo.Length - FTPFilesize;
//ftprequest.Method = WebRequestMethods.Ftp.UploadFile;
}
else
{
ftprequest.Method =
WebRequestMethods.Ftp.UploadFile;
}
ftprequest.UsePassive =
false;
ToWriteStream = ftprequest.GetRequestStream();
//response = (FtpWebResponse)ftprequest.GetResponse();
fstr =
new FileStream(file_to_upload, FileMode.Open);
fstr.Seek(FTPFilesize,
SeekOrigin.Begin);
byte[] buffer = new byte[bufferLength];
pointer = fstr.Read(buffer, 0, bufferLength);
startuptime =
DateTime.Now;
Exoccur(
"Resuming Upload..");
while (pointer != 0)
{
ToWriteStream.Write(buffer, 0, pointer);
Appendinglength += pointer;
int prg = CalculateProgress(Appendinglength, TotalLength);
PrgUpdate(prg);
//lblupdate(prg);
pointer = fstr.Read(buffer, 0, bufferLength);
}
break;
}
catch
{
}
}
enduptime =
DateTime.Now;
ToWriteStream.Close();
fstr.Close();
TimeSpan timetaken = enduptime.Subtract(startuptime);
double d = timetaken.TotalMilliseconds;
d = d / 1000;
Exoccur(
Convert.ToString(d));
}
else
{
Exoccur(
"File Doesnt occur");
}
return true;
}