通过以下方式,我可以阅读。
但是没有 dispose 方法,所以我以后无法删除该文件。
所以下面的方法失败了。
我想不出一个合适的解决方案。
在 C# 4.5 WPF 应用程序中无法识别位图类。
谢谢你
DirectoryInfo dInfo = new DirectoryInfo(@"C:\pokemon_files\images\");
FileInfo[] subFiles = dInfo.GetFiles();
BitmapImage myImg;
foreach (var vrImage in subFiles)
{
string srFilePath = vrImage.FullName;
System.Uri myUri = new Uri(srFilePath);
myImg = new BitmapImage(myUri);
if (myImg.Width < 50)
{
File.Delete(srFilePath);
continue;
}
}