标签:live bre read 图片 red use orm bit try
public string GetFtpBase64String(string FtpFilePath)
{
try
{
string sBase64String = string.Empty;
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(FtpFilePath));
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.UseBinary = true;
request.Credentials = new NetworkCredential(sFtpUserName, sFtpPassword);
request.UsePassive = false;
request.KeepAlive = false;
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
{
using (Stream ftpStream = response.GetResponseStream())
{
using (Bitmap bmp = new Bitmap(ftpStream))
{
using (MemoryStream ms = new MemoryStream())
{
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
sBase64String = Convert.ToBase64String(arr);
}
}
}
}
return sBase64String;
}
catch (Exception ex)
{
return "";
}
}
标签:live bre read 图片 red use orm bit try
原文地址:https://www.cnblogs.com/Elcser/p/10409875.html