如何打開,選擇和添加c#中的表單中的一個唯一的jpeg格式文件從計算機的任何目錄?這是代碼。打開,選擇並添加一個表格內的.jpg文件
private void open2ToolStripMenuItem_Click(object sender, EventArgs e)
{
pictureBox1.Visible = true;
string Chosen_File = "";
Chosen_File = openFileDialog1.FileName;
openFileDialog1.Title = "Insert an image";
openFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog1.FileName ="";
openFileDialog1.Filter = "JPEG Images|*.jpg|GIF Images|*.gif|All Files|";
openFileDialog1.ShowDialog();
if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
{
Chosen_File = openFileDialog1.FileName;
pictureBox1.Image = Image.FromFile(Chosen_File);
}
}
其只能打開格式圖片不加載裏面的形式 – user3668974
任何人都可以幫忙嗎? – user3668974
我沒有看到你的代碼中的任何問題,它的工作原理 – Sajeetharan