In my program I am currently using SaveFileDialog
to output a .txt file to the user specified path like so:
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "filename.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
//Open file, print text, close file
File.WriteAllLines(dlg.FileName, stringArray);
}
Now I am at a point where I need to add more files to this location. So instead of naming a single file and saving it, I need to name multiple files and save them to the location specified by SaveFileDialog
.
I want my new structure to be something like this:
UPDATE:
//Call functions to create string arrays to write to .txt files
createArrayForFile1();
createArrayForFile2();
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "File1";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
//Create, print, and close both files
File.WriteAllLines(dlg.FileName, stringArray1);
directory = Path.GetDirectoryName(dlg.FileName);
Path.Combine(directory, "File2");
}
How do I write several files to a location specified by SaveFileDialog
?