title: C# - setting a user defined folder path as a string variable the first time a program is run
body: <p>Thanks to you all for the help so far! I am extremely new to c# and code in general. I have a question that I cannot seem to find the answer to.</p>
  
  <p>I just wrote a simple program that moves files from one folder to a new folder named that day's date. Please see below:</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
  
              DateTime now = DateTime.Now;
              string date = (now.ToString("D"));
  
              string a = @"m:\\staff docs\\faxes\\";
              string b = @a + date + "\\";
              System.IO.Directory.CreateDirectory(b);
  
  
          DirectoryInfo dir1 = new DirectoryInfo("c:\\blah");
          DirectoryInfo dir2 = new DirectoryInfo("@b");
  
          FileInfo[] DispatchFiles = dir1.GetFiles();
          if (DispatchFiles.Length &gt; 0)
          {
              foreach (FileInfo aFile in DispatchFiles)
              {
                  string files = @b + aFile.Name;
                  int count = 0;
              Find :
                  if (File.Exists(files))
                  {
                      files = files + "(" + count.ToString() + ").txt";
                      count++;
                      goto Find;
                  }
                  aFile.MoveTo(files);
              }
          }   
      {
          MessageBox.Show("Your files have been moved!");
  </code></pre>
  
  <p>I'd like to have the user define the source folder variable and the destination folder variable, either by having them navigate to the folder in a file browser, or a Console.ReadLine - but not every time they run the program, just the first.  It would be ideal if they could change the path if they wanted to later on as well.</p>
  
  <p>Many thanks!</p>
  
  <p>EDIT</p>
  
  <p>My solution was a Button on my Form that calls this block:</p>
  
  <pre><code>private void button3_Click(object sender, EventArgs e)
  {
   FolderBrowserDialog fbd = new FolderBrowserDialog();
          fbd.Description = "Select source folder";
          fbd.ShowDialog();
          string Source = fbd.SelectedPath;
          Properties.Settings.Default.source = Source;
          Properties.Settings.Default.Save();
  
          FolderBrowserDialog fbd2 = new FolderBrowserDialog();
          fbd2.Description = "Select destination folder";
          fbd2.ShowDialog();
          string d1 = fbd2.SelectedPath;
          string d2 = "\\";
          string Destination = d1 + d2;
          Properties.Settings.Default.destination = Destination;
          Properties.Settings.Default.Save();
  }
  </code></pre>