Reputation: 703
I have a c# program that is saving data a user enters to a hidden xml file. I want to be able to store the file name of the particular xml file so that when the user exits the progrma and re-enters it again they can select the name of that file from a drop-down list and load the data stored into that xml file into another form. I was thinking about saving the name of the file to an array list since they are dynamic but am having trouble finding a way to save or hold onto the values in this array list so that they can be assigned to a comboBox on a form whenever the user enters the application. Does anyone have any suggestions or ideas?
Upvotes: 2
Views: 461
Reputation: 236228
.settings
file to your project.StringCollection
typeNow your settings will be available from code this way:
combobox.DataSource = Settings.Default.HiddenFiles;
If you want to add another file name to this list (which will be available after this user starts application later):
if (Settings.Default.HiddenFiles == null)
Settings.Default.HiddenFiles = new StringCollection();
Settings.Default.HiddenFiles.Add(pathToFile);
Settings.Default.Save();
Upvotes: 1
Reputation: 703
Here is the code that is producing an exception during run-time.
Settings1.Default.eventSaveArrayList.Add(clubNameTextBox.Text.ToString() + " " + DateString); Settings1.Default.Save();
Upvotes: 0
Reputation: 25521
If you are saving the XML file to disk, why not just read the directory for a list of files on the start of your application and then populate a drop-down with the file names you retrieved?
Upvotes: 2