Mehmet Fatih

Mehmet Fatih

  • 851
  • 941
  • 42.4k

Automatically clicking OK button without displaying ShowDialog window

Jan 27 2024 2:05 PM

I am using two ShowDialog windows. I want to save the second file in the folder where I saved the first file. Before saving a file, I want to press the OK button without displaying the second ShowDialog window. Or I want to save it to the same location without viewing it at all. How will we achieve this?

 

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title = "Excele Aktar";
            sfd.Filter = "Excel (xlsx)|*.xlsx";
            sfd.FileName = "Ögrencibil";

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                Export_DataGridView_To_Excel(DGV, sfd.FileName);
            }

SaveFileDialog sfd2 = new SaveFileDialog();

sfd2.Title = "Worde Aktar";
sfd2.Filter = "Word (doc)|*.docx";
sfd2.FileName = "Ögrencibil";


if (sfd2.ShowDialog() == DialogResult.OK)
{
    string wordosyam = Path.GetFullPath(sfd2.FileName);

}


Answers (2)