I am trying to write a program that sorts images in a specific folder by ther parameters and moves small images to another folder through a simple .NET console application. I decided to use the System.Drawing.Image class to get the sizes of the images from the image file. But I ran into the following error:
Cannot find the name of the type or namespace "Image" (you donβt see using the directive or link to the assembly?)
What exactly did I do wrong and why does he not see this class? Here is the complete code for my program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Drawing; namespace ImageSort { class Program { static void Main(string[] args) { string targetPath = @"d:\SmallImages"; string[] files = Directory.GetFiles(@"d:\Images"); foreach (string path in files) { if (File.Exists(path)) { Image newImage = Image.FromFile(path); var Width = (int)(newImage.Width); var Height = (int)(newImage.Height); if (Width * Height < 660000) { System.IO.File.Move(path, targetPath); } } } } } }
source share