我想將圖像保存在特定位置。繞過「確認另存爲,是否要替換它」彈出。SaveFileDialog選擇圖像後保存文件(雙擊)
private void pictureBox1_Click(object sender, EventArgs e)
{
string path = "C:\\MyDocs\\TimeIn&Out\\EmployeesPhoto";
Directory.CreateDirectory(path);
saveFileDialog1.InitialDirectory = (@"C:\");
saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.Title = "Select Image";
saveFileDialog1.DefaultExt = ".png";
saveFileDialog1.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
saveFileDialog1.OverwritePrompt = false;
if(saveFileDialog1.ShowDialog()==DialogResult.OK)
{
//path = Path.GetDirectoryName(saveFileDialog1.FileName);
//pictureBox1.Image.Save(path, System.Drawing.Imaging.ImageFormat.Png);
// I tried this 2 but not working
}
}
點擊picturebox1 =>之後選擇目錄中的圖像=>然後它必須將圖像保存在「路徑」中。但它顯示了這個彈出窗口。
你是什麼意思將路徑保存圖像?你想將它保存到一個文件夾或文件? – Lloyd
我想保存它的文件夾。路徑是我聲明的目錄 – Vincent
那麼爲什麼你使用'SaveFileDialog'而不是'FolderBrowserDialog'? – Lloyd