I use Image.FromFile(string) method in this situation:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GVEMO
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
PaintBackground();
}
public void PaintBackground() {
gameBoard.Image = Image.FromFile("gvemoBack.jpg");
}
}
}
gameBoard is name for pictureBox. But when I started this program, I get exception FileNotFound. Image is in main directory (directory with folders bin,classes,properties etc.) I try copy this image into all project directories but exception remain. In which directory must be this image or what I do wrong? I use VS2012 and .NET framework version 4.5. Thx