MyDocument 以下の m3u ファイルを削除する,m3uCleanerのソースコード。
恥ずかしいくらい簡単なコードです。(エラーハンドリングは省略しています)
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Text = "完了しました。5秒後に終了します。\r\n \r\n";
foreach (string stFilePath in Directory.GetFiles("\\My Documents\\", "*.m3u"))
{
this.textBox1.Text += Path.GetFileNameWithoutExtension(stFilePath) + " 削除\r\n";
File.Delete(stFilePath);
}
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close();
}
Foreach + Directory.GetFiles で m3uファイルを探します。探したら、画面に表示しつつ、File.Delete で削除するだけ。
終わったら、(あらかじめ5秒にセットされた)タイマーを起動して、タイマーの時間になったら(Tick) アプリケーションの終了です。
簡単♪