Winform OpenFileDialog、開くたびにメモリが増加し、dispose () と OpenFileDialog = null が機能しませんが、メモリは失われません。.
これを修正する方法??
private void btnLocalPicture_Click(object sender, EventArgs e)
{
OpenFileDialog ofdSelectPicture = new OpenFileDialog();
ofdSelectPicture.Filter = "PicFile|*.jpg;*.png;*.jpeg;*.gif;*.bmp;*.tif";
if (ofdSelectPicture.ShowDialog() == DialogResult.OK)
{
if (showPicture != null)
showPicture.Dispose();
showPicture = Image.FromFile(ofdSelectPicture.FileName);
if (pbShowPicture.Image != null)
pbShowPicture.Image.Dispose();
pbShowPicture.Image = showPicture;
path = ofdSelectPicture.FileName;
WordTip.Visible = false;
if (pbShowPicture.Image != null)
picOK.Enabled = true;
}
ofdSelectPicture.Dispose(); //not working
ofdSelectPicture = null; //not working
GC.Collect();
}