回答編集履歴
3
修正
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
{
|
32
32
|
|
33
|
-
string[] path
|
33
|
+
string[] paths = System.IO.Directory.GetFiles("images/");
|
34
34
|
|
35
35
|
|
36
36
|
|
2
修正
test
CHANGED
@@ -8,7 +8,9 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
[こちら](https://teratail.com/questions/84145)の質問にも書きましたが
|
11
|
+
[こちら](https://teratail.com/questions/84145)の質問にも書きましたが
|
12
|
+
|
13
|
+
イメージとしては以下のような感じで判定します。
|
12
14
|
|
13
15
|
|
14
16
|
|
1
修正
test
CHANGED
@@ -5,3 +5,91 @@
|
|
5
5
|
エラーが出たら処理をやめる。エラーが出なければ処理を継続する
|
6
6
|
|
7
7
|
という風にすることが私の場合は多いです。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
[こちら](https://teratail.com/questions/84145)の質問にも書きましたがイメージとしては以下のような感じです。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```C#
|
16
|
+
|
17
|
+
using System;
|
18
|
+
|
19
|
+
using System.Drawing;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
class Program
|
24
|
+
|
25
|
+
{
|
26
|
+
|
27
|
+
static void Main(string[] args)
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
string[] pathes = System.IO.Directory.GetFiles("images/");
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
foreach (string path in paths)
|
36
|
+
|
37
|
+
{
|
38
|
+
|
39
|
+
try
|
40
|
+
|
41
|
+
{
|
42
|
+
|
43
|
+
Bitmap bmp = new Bitmap(path);
|
44
|
+
|
45
|
+
Console.WriteLine($"*{path}は画像です。");
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
catch
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
Console.WriteLine($" {path}は画像ではありません。");
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Console.ReadKey();
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
*images/00.jpgは画像です。
|
72
|
+
|
73
|
+
images/01.gifは画像ではありません。
|
74
|
+
|
75
|
+
*images/02.gifは画像です。
|
76
|
+
|
77
|
+
images/03.pngは画像ではありません。
|
78
|
+
|
79
|
+
images/04.psdは画像ではありません。
|
80
|
+
|
81
|
+
images/05.psdは画像ではありません。
|
82
|
+
|
83
|
+
images/06.bmpは画像ではありません。
|
84
|
+
|
85
|
+
*images/07.bmpは画像です。
|
86
|
+
|
87
|
+
*images/08.jpgは画像です。
|
88
|
+
|
89
|
+
*images/09.jpgは画像です。
|
90
|
+
|
91
|
+
*images/10.pngは画像です。
|
92
|
+
|
93
|
+
*images/11.jpgは画像です。
|
94
|
+
|
95
|
+
```
|