D
Deep
Dear Friends
I am using FtpWebRequest to upload file. But it is slow Can you
please provide me any method to do it fast
this is my code
public string uploadFileUsingFTP(byte[] fileStream,
CashmanUpload.CashmanUploadService.EventImageVariable eventVariable)
{
// get the ftppath from config file and the image loctaion
//from input parameters
string CompleteFTPPath = eventVariable.UploadImagepath +
eventVariable.ImageName;
// set the ftp userid
string UName =
Convert.ToString(eventVariable.refFTPUserID);
// set the ftp password
string PWD =
Convert.ToString(eventVariable.refFTPPassword);
string retrunvalue = "";
CashmanUpload.CashmanUploadService.UploadService
uploadService =
new CashmanUpload.CashmanUploadService.UploadService();
try
{
if (!
uploadService.CheckImageExitsservice(eventVariable))
{
//Create a FTP Request Object and Specfiy a
Complete Path
FtpWebRequest reqObj =
(FtpWebRequest)FtpWebRequest.Create(new Uri(CompleteFTPPath));
reqObj.KeepAlive = false;
// set the maximum timeout for upload the heavy
images
reqObj.Timeout = 10000000;
// set the maximum write timeout for upload the
heavy images
reqObj.ReadWriteTimeout = 10000000;
//If you want to access Resourse Protected You
need to give User Name and PWD
reqObj.Credentials = new NetworkCredential(UName,
PWD);
//Call A FileUpload Method of FTP Request
Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
// Copy the contents of the file to the request
stream.
reqObj.ContentLength = fileStream.Length;
// create the Stream object to write the file on
FTP
Stream requestStream = reqObj.GetRequestStream();
requestStream.Write(fileStream, 0,
fileStream.Length);
requestStream.Close();
// get the final response
FtpWebResponse response =
(FtpWebResponse)reqObj.GetResponse();
response.Close();
// if sucessfull the reurn OK
retrunvalue = "OK";
}
else
{
// else retrun NOTDONE to retry the same image
again
retrunvalue = "NOTDONE";
}
}
catch (Exception ex)
{
UserExceptionLog.CreateExceptionLog(ex);
//MessageBox.Show(ex.Message + " function name is
uploadFileUsingFTP 731");
}
return retrunvalue;
}
I am using FtpWebRequest to upload file. But it is slow Can you
please provide me any method to do it fast
this is my code
public string uploadFileUsingFTP(byte[] fileStream,
CashmanUpload.CashmanUploadService.EventImageVariable eventVariable)
{
// get the ftppath from config file and the image loctaion
//from input parameters
string CompleteFTPPath = eventVariable.UploadImagepath +
eventVariable.ImageName;
// set the ftp userid
string UName =
Convert.ToString(eventVariable.refFTPUserID);
// set the ftp password
string PWD =
Convert.ToString(eventVariable.refFTPPassword);
string retrunvalue = "";
CashmanUpload.CashmanUploadService.UploadService
uploadService =
new CashmanUpload.CashmanUploadService.UploadService();
try
{
if (!
uploadService.CheckImageExitsservice(eventVariable))
{
//Create a FTP Request Object and Specfiy a
Complete Path
FtpWebRequest reqObj =
(FtpWebRequest)FtpWebRequest.Create(new Uri(CompleteFTPPath));
reqObj.KeepAlive = false;
// set the maximum timeout for upload the heavy
images
reqObj.Timeout = 10000000;
// set the maximum write timeout for upload the
heavy images
reqObj.ReadWriteTimeout = 10000000;
//If you want to access Resourse Protected You
need to give User Name and PWD
reqObj.Credentials = new NetworkCredential(UName,
PWD);
//Call A FileUpload Method of FTP Request
Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
// Copy the contents of the file to the request
stream.
reqObj.ContentLength = fileStream.Length;
// create the Stream object to write the file on
FTP
Stream requestStream = reqObj.GetRequestStream();
requestStream.Write(fileStream, 0,
fileStream.Length);
requestStream.Close();
// get the final response
FtpWebResponse response =
(FtpWebResponse)reqObj.GetResponse();
response.Close();
// if sucessfull the reurn OK
retrunvalue = "OK";
}
else
{
// else retrun NOTDONE to retry the same image
again
retrunvalue = "NOTDONE";
}
}
catch (Exception ex)
{
UserExceptionLog.CreateExceptionLog(ex);
//MessageBox.Show(ex.Message + " function name is
uploadFileUsingFTP 731");
}
return retrunvalue;
}