teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

編集

2019/12/04 14:16

投稿

退会済みユーザー
answer CHANGED
@@ -65,8 +65,6 @@
65
65
  Console.WriteLine(int.Parse(Path.GetFileNameWithoutExtension(fn)));
66
66
  File.Delete(fn);
67
67
  }
68
-
69
- Console.ReadKey();
70
68
  }
71
69
  }
72
70
  }

1

編集

2019/12/04 14:16

投稿

退会済みユーザー
answer CHANGED
@@ -39,4 +39,36 @@
39
39
  }
40
40
  }
41
41
  }
42
+ ```
43
+ ```C#
44
+ using System;
45
+ using System.IO;
46
+
47
+ namespace Sample
48
+ {
49
+ class Program
50
+ {
51
+ static void Main(string[] args)
52
+ {
53
+ Console.WriteLine("出力様式");
54
+
55
+ for (int i = 0; i < 5; i++)
56
+ {
57
+ Console.Write("値を入力 ");
58
+ string fn = Console.ReadLine().PadLeft(10, '0') + ".txt";
59
+ StreamWriter sw = new StreamWriter(fn);
60
+ sw.Close();
61
+ }
62
+
63
+ foreach (string fn in Directory.GetFiles(Environment.CurrentDirectory, "*.txt"))
64
+ {
65
+ Console.WriteLine(int.Parse(Path.GetFileNameWithoutExtension(fn)));
66
+ File.Delete(fn);
67
+ }
68
+
69
+ Console.ReadKey();
70
+ }
71
+ }
72
+ }
73
+
42
74
  ```