Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

  1. Add .settings file to your project.
  2. In settings editor provide name for your list of hidden files (e.g. HiddenFiles)
  3. Select StringCollection type
  4. Select scope (by default it is User)
  5. Provide values in value editor.

Now 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();

Here is the code that is producing an exception during run-time.

Settings1.Default.eventSaveArrayList.Add(clubNameTextBox.Text.ToString() + " " + DateString); Settings1.Default.Save();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top