显示远程图像

时间:2013-04-24 16:38:20

标签: c# image

我的网络服务器上有一个包含图像的目录,我正在尝试如何在Windows窗体上显示它们。

我正在运行查询以获取所需记录的图像名称,以便完成部分。然后我如何显示该图像。这是到目前为止的代码:

string FltLogoVal = myReader.GetString("Logo");
FltLogo.Text = FltLogoVal;

PictureBox imageControl = new PictureBox();
imageControl.Width = 150;
imageControl.Height = 50;

Bitmap image = new Bitmap("http://www.maydomain.com/airline_logos/").FltLogo.Text;
imageControl.Dock = DockStyle.Fill;
imageControl.Image = (Image)image;

Controls.Add(imageControl); 

我收到的错误是:

Bitmap image = new Bitmap("http://www.mydomain.com/airline_logos/").FltLogo.Text;

错误是: 'System.Drawing.Bitmap'不包含'FltLogo'的定义,也没有找到接受类型'System.Drawing.Bitmap'的第一个参数的扩展方法'FltLogo'(你是否缺少using指令或程序集引用?)

我有两个问题:

  1. 我是否以正确的方式解决这个问题?
  2. 如果有的话,任何人都可以看到我出错的地方。
  3. 正如您所看到的,我对C#非常陌生,所以请回复任何回复。

2 个答案:

答案 0 :(得分:0)

您需要将图片名称附加到网址:

Bitmap image = new Bitmap("http://www.maydomain.com/airline_logos/" + FltLogo.Text);

答案 1 :(得分:0)

错误表示您正在尝试在Bitmap构造函数上调用FltLogo.Text方法。如果我从您的代码中获得正确的想法,那么您的意思更像是

Bitmap image = new Bitmap("http://www.maydomain.com/airline_logos/" + FltLogoVal)

相关问题