title: How to read randomly generated folder name in OuterHtml
body: <p>Please excuse this lengthy question. I've written a C# App that uses WebClient.DownloadFileAsync to pull down and save a file to a client computer.</p>
  
  <p>This works successfully for a pdf file, whose Internet folder location doesn't change. However, I'm also trying to download some audio files with a .mp3.zip extension.</p>
  
  <p>If I input the URL for these files, I'm taken directly to the file download site where I'm presented with a dialog to either select individual files or click a link to "Download All Files". </p>
  
  <p>I want to programmatically download the entire .mp3.zip file.</p>
  
  <p>The problem with the "Download All Files" link is that, it appears to include a random folder naming scheme in its URL.
  For example, <a href="http://download.site.org/files/audio_books/" rel="nofollow noreferrer">http://download.site.org/files/audio_books/</a><strong>xx</strong>/zipfile.mp3.zip; the xx being a changing folder location.</p>
  
  <p>If the URL for the audio files always had the same exact location, I could use WebClient.DownloadFileAsync without a problem.
  I'm able to manually read the Outer HTML if I inspect the element for the link, but I've observed that this (xx) changes monthly.</p>
  
  <p>If I could find a way to successfully parse the URL in the Download link, I could verify what the current (xx) folder name is and then use WebClient normally. </p>
  
  <p>I've been all over the Internet and read through numerous StackOverFlow articles, for example <a href="https://stackoverflow.com/questions/12985673/grabbing-just-the-url-of-an-href-using-htmlagilitypack">Grabbing just the URL of an href using HTMLAgilityPack</a>, and <a href="https://stackoverflow.com/questions/11044362/image-scraper-with-c-sharp">Image scraper with C#</a>, but none of the suggestions appear to return the (xx) folder name contained in the Outer HTML.</p>
  
  <hr>
  
  <p>I came across another post on SOF, which appears to be the closest answer to my question, i.e. 
  <a href="https://stackoverflow.com/questions/6838947/how-to-parse-inner-html-in-c-sharp">Parse inner HTML</a></p>
  
  <p>This is what I've tried, but it throws a NullReferenceException. </p>
  
  <pre><code>HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
  req.Method = "GET";
  req.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US))";
  string source;
  using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
  {
      source = reader.ReadToEnd();
  }
  HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
  doc.LoadHtml(source);
  string hrefValue = doc.DocumentNode
      .Descendants("div")
      .Where(x =&gt; x.Attributes["class"].Value == "flRight")
      .Select(x =&gt; x.Element("a").Attributes["href"].Value)
      .FirstOrDefault();
  </code></pre>
  
  <p>Can anyone suggest why the where clause querying the class.value is throwing the exception, or what is needed? I feel I'm really close to solving this issue, because if I inspect the element of the download button, I can see what I need in a div class.</p>
  
  <p>P.S. is the only way to ask additional questions to edit my original post, or the limited text comment box?</p>