
protected void Page_Load(object sender, EventArgs e)
{
Image1.ImageUrl = GetImageBase64("ftp://192.168.1.212:2020/1.jpg");
}
public string GetImageBase64(string ftpPath)
{
FtpWebRequest reqFTP;
try
{
// 根据uri创建FtpWebRequest对象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpPath));
// 指定执行

这篇博客展示了如何在ASP.NET应用程序中从FTP服务器下载图片并将其转换为Base64字符串。通过创建`FtpWebRequest`对象设置FTP连接参数,然后读取下载的文件内容到内存流,最后将内存流转换为Base64编码的字符串,以供网页直接显示。
最低0.47元/天 解锁文章
826

被折叠的 条评论
为什么被折叠?



