【发布时间】:2016-09-02 02:48:05
【问题描述】:
我正在尝试编写一个程序,该程序按尺寸对特定文件夹中的图像进行排序,并通过简单的 .NET 控制台应用程序将小图像移动到另一个文件夹。我决定使用 System.Drawing.Image 类从图像文件中获取图像尺寸。但我面临以下错误:
找不到类型或命名空间名称“Image”(您是否缺少 using 指令还是程序集引用?)
我到底做错了什么,为什么它没有看到这个类? 以下是我的程序的完整代码:
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);
}
}
}
}
}
}
【问题讨论】:
标签: c# .net image dimensions