So I am trying to make a method that will create PictureBoxes as need be, and the specific image that I am trying to load onto the Image is flying the error;
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
Additional information:
\students\student\30232634\My Documents\Visual Studio 2015\Projects\WindowsFormsApplication4\WindowsFormsApplication4\bin\Debug/Graphics/enemyAlien.png
The Code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
namespace WindowsFormsApplication4
{
class Aliens : PictureBox
{
public string alienImage = "Enemy.png";
public int alienCount = 30;
public int posX { get; set; }
public int posY { get; set; }
public Aliens AlienSpawn()
{
Aliens picture = new Aliens();
picture.Name = "pictureBox";
picture.Size = new Size(64, 64);
picture.Location = new Point(100, 100);
picture.Image =Image.FromFile(Directory.GetCurrentDirectory()+"/Graphics/enemyAlien.png");
return picture;
}
}
}