表示中の画像ファイルが削除できない問題の解決法「ピクチャボックスに簡単に画像を表示する」や「画像ファイルを表示する」で紹介したように画像ファイルを表示した時は、その画像ファイルがロックされてしまい、削除する事が出来なくなります(ファイル名の変更や、ファイルの上書き保存もできません)。この問題の回避法は「マイクロソフト サポート技術情報 - 309482」にある通り、FileStreamオブジェクトを使用することです。 Dim fs As System.IO.FileStream fs = New System.IO.FileStream("C:\Blue hills.jpg", _ IO.FileMode.Open, IO.FileAccess.Read) PictureBox1.Image = System.Drawing.Image.FromStream(fs) fs.Close()
System.IO.FileStream fs;
fs = new System.IO.FileStream(@"C:\Blue hills.jpg",
System.IO.FileMode.Open, System.IO.FileAccess.Read);
PictureBox1.Image = System.Drawing.Image.FromStream(fs);
fs.Close();
(この質問は掲示板でいただいた質問です。) 注意:この記事では、基本的な事柄の説明が省略されているかもしれません。初心者の方は、特に以下の点にご注意ください。 |
|
Copyright(C) DOBON!. All rights reserved.
|