-4

I want to save my pictures in silent. I mean without showing the save file box here is save picture code.

string path = textBox1.Text.ToString();
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpg|*.jpg";
saveFileDialog1.InitialDirectory = path;
saveFileDialog1.AddExtension = false;
saveFileDialog1.FileName = fileName;
saveFileDialog1.OverwritePrompt = false;
saveFileDialog1.DefaultExt = ".jpg";
this.Invoke(new MethodInvoker(delegate ()
{
  if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  {
    Uri realLink = new Uri(link);
    WebClient wc = new WebClient();
    wc.DownloadFileAsync(realLink, saveFileDialog1.FileName);
  }
}));
Aleks Andreev
  • 7,016
  • 8
  • 29
  • 37

1 Answers1

2

From the code you posted it seems you already know the path and file name. So you can simply:

string destination = Path.Combine(textBox1.Text.ToString(), fileName);
Uri realLink = new Uri(link);
WebClient wc = new WebClient();
wc.DownloadFileAsync(realLink, destination);
René Vogt
  • 43,056
  • 14
  • 77
  • 99