if (File1.PostedFile.FileName != "")
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://192.168.1.112:22/FtpTest/FtpReceive/" + Path.GetFileName(File1.PostedFile.FileName));
request.Credentials = new NetworkCredential("XXXX", "XXXX");
request.KeepAlive = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UseBinary = true;
Stream inputStream = File1.PostedFile.InputStream;
long len = inputStream.Length;
request.ContentLength = len;
Stream requestStream = request.GetRequestStream();
try
{
int count = 0;
byte[] buffer = new byte[2048];
while ((count = inputStream.Read(buffer, 0, buffer.Length)) > 0)
{
requestStream.Write(buffer, 0, count);
}
}
catch
{
}
finally
{
inputStream.Close();
inputStream.Dispose();
requestStream.Close();
requestStream.Dispose();
}
}