title: How to get the name of a folder on a website
body: <p>I'm looking for a way for me to get the folder name which is located on (for example) <code>http://example.com/download/"foldername here"</code></p>
  
  <p>The reason for this is because I have a c# program which always downloads a .zip if you don't allready have it, but currently it won't download a new version.</p>
  
  <p>Example: Currently it downloads from <code>http://example.com/download/1.0/file.zip</code>, if you allready have the folder it checks for, it won't download it, but if you do have that folder, it won't download from <code>http://example.com/download/2.0/file.zip</code>, which contains the new version. I have made a file which contains the current version, but how can I get my program to check that file against the folder in which the newest version resides?</p>
  
  <p>Edit: I reworked my code so it downloads a <code>version.txt</code> file first and reads it contents, which contains the latest version of the download.</p>
  
  <p>Code:</p>
  
  <pre><code>if (radUseFile.Checked)
  {
  //get latest version on website
  WebClient modver = new WebClient();
  modver.UseDefaultCredentials = true;
  modver.DownloadFile("http://www.example.com/download/version.txt", tempdir _
  + "version.txt");
  using (StreamReader ver = new StreamReader(tempdir + "version.txt"))
  {
      siteversion = ver.ReadToEnd();
  }
  File.Delete(tempdir + "version.txt");
  if (Directory.Exists(folder))
  {
      if (File.Exists(folder + "\\version.txt"))
      {
          using (StreamReader sr = new StreamReader(folder + "\\version.txt"))
          {
              latestversion = sr.ReadToEnd();
          }
          if (latestversion != siteversion)
          {
              uptodate = false;
          }
          else
          {
              uptodate = true;
          }
      }
  }
  else
  {
      uptodate = false;
  }
  if (!uptodate)
  {
      //download and extract the files
      WebClient downloader = new WebClient();
      label4.Text = "Downloading full client. May take a while";
      this.Update();
      downloader.UseDefaultCredentials = true;
      downloader.DownloadFile("http://www.example.com/download" + siteversion _
  + "/zipfile.zip", templocation + "zipfile.zip");
  
      label4.Text = "Extracting...";
      Shell32.Shell sc = new Shell32.Shell();
      Directory.CreateDirectory(tempdir);
      Shell32.Folder output = sc.NameSpace(tempdir);
      Shell32.Folder input = sc.NameSpace(tempdir + "zipfile.zip");
      output.CopyHere(input.Items(), 4);
  
      label4.Text = "Cleaning up...";
      File.Delete(tempdir + "zipfile.zip");
  
      new Microsoft.VisualBasic.Devices.Computer().FileSystem.CopyDirectory(tempdir,_
  folderlocation, true);
  
      Directory.Delete(tempdir, true);
  
      uptodate = true;
  }
  }
  else
  {
  uptodate = true;
  }
  </code></pre>
  
  <p>This works for now, but I'm pretty sure this code can be improved, or the entire method as to how it takes the latest version</p>