用form.BackgroundImage = Image.FromFile(@"D:\image.jpg");语句后,我想再别的地方取得背景图片的本地路径该怎么办?

解决方案 »

  1.   

    你用一个string来保存你的路径不就可以了,
    像这样:
    public static string filepath = @"D:\image.jpg";
    form.BackgroundImage = Image.FromFile(filepath);
    你在直接取filepath不就可以了。
      

  2.   

    可以把地址字符串放在资源文件里
      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
      this.PictureBox1.BackgroundImage = resources.GetString("imgfilepath")));
      

  3.   

    public static string filepath = @"D:\image.jpg"; 
    form.BackgroundImage = Image.FromFile(filepath);