Upload Image on ftp server using winform C#

Опубликовано: 20 Декабрь 2021
на канале: IT Core Soft
2,562
21

Download google drive here : https://drive.google.com/file/d/1EVX1...
My fiverr link: https://www.fiverr.com/hamzakhalid178
My Upwork Profile: https://www.upwork.com/freelancers/~0...

Whatsapp Number: +923338672398


add namespace:
using System.IO;
using System.Net;

code of FTPHelper

public FTPHelper(string address,string login,string password)
{
Address = address;
Login = login;
Password = password;
}
public string Upload(MemoryStream stream,string fileName)
{
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Address + @"/" + fileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(Login,Password);
request.UseBinary = true;
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
return "successful";
}
catch(Exception ex)
{
return ex.InnerException.ToString();
}
}
public string Address { get; set; }
public string Login { get; set; }
public string Password { get; set; }


code of button:

byte[] data;
using(Image image=Image.FromFile(@"C:/Users/923400221916/Desktop/uploadpicture.jpg"))
{
using(MemoryStream m=new MemoryStream())
{
image.Save(m, image.RawFormat);
data = m.ToArray();
}
}
FTPHelper fTPHelper = new FTPHelper("ftp://ipaddress:portnumber/images/", "username", "password");
string result = fTPHelper.Upload(new MemoryStream(data), "Uploadedpicturename.jpeg");
MessageBox.Show(result);


please contact us for custom softwares:
comment on the video if any question.


Смотрите видео Upload Image on ftp server using winform C# онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь IT Core Soft 20 Декабрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,562 раз и оно понравилось 21 людям.