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);
}
Mayooran NavamanyPosted Jan 27, 2024, 3:35 PM
If you want to save the second file in the same location as the first file without displaying the second
SaveFileDialog, you can achieve this by extracting the directory from the first file's path and then appending the desired file name for the second file.This way, after saving the first file, the code constructs the path for the second file in the same directory without displaying the second
SaveFileDialog. You can adjust the file name and extension as needed.Mehmet FatihPosted Jan 27, 2024, 9:15 PM
Thank you very much. Mayooran Navamany. It works fine.