I am working with a client application that needs to have a local repository to save updates made to a group of objects, called "Books". However, I am not able to save the objects back into the SQL server until the entire book has been updated. So the powers that be have decided to use an excel file as a repository, we are calling a work list.
The user has to be able to name the work list so that it is meaningful to them, but they cannot be able to edit the work list in excel. My idea was to create a hidden folder to store the work lists, and the app can retrieve them from that location.
Here is my question: Is there a way to keep the windows dialog box hidden, so the user cannot choose where the file is saved to, yet pass a name to the dialog for the work list?
I am using the standard Microsoft.Win32.SaveFileDialog currently, but I can change, if I need to, in order to accomplish this task.
Here is my SaveFileDialog code, that allows the user to change the name but also the path to where the file saves:
public void SaveToFile(string BookName)
{
var file = "";
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = string.Format("{0} \\{1} Codes", WORKLIST_SAVE_PATH, BookName); // Default file name
dlg.DefaultExt = ".xlsx"; // Default file extension
dlg.Filter = " Excel Files (.xlsx)|*.xlsx"; // Filter files by extension
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
// Save document
file = dlg.FileName;
}
else return;
File.WriteAllText(file, Export(true));
}