title: Error reading xml files in ftp with XDocument.Parse
body: <p>I try to read xml in four ftp folder
  Often (7 times on 10) i recive errors about xml files (like 'unexpected end of file has occured' etc) but files are 100% corrects.</p>
  <p>I read xml to return list of orders headers in files.</p>
  <p>Is WebClient best way?</p>
  <pre><code>private static async Task&lt;List&lt;Order&gt;&gt;GetOrdersFromFolder(List&lt;string&gt;filesList,string folder)
  {
    var orders = new List&lt;Order&gt;();
  
          foreach (var file in filesList)
          {
              var extension = Path.GetExtension(file);
              if (extension == &quot;.xml&quot;)
              {
                  WebClient request = new WebClient(); 
                  string url = &quot;ftp://xxxxxxx/&quot; + &quot;myfiles/&quot; + folder + &quot;/&quot; + file;
                  request.Credentials = new NetworkCredential(&quot;user&quot;, &quot;pwd&quot;);
                  var stringData = await request.DownloadStringTaskAsync(url);
  
                  XDocument doc = XDocument.Parse(stringData);
                  IEnumerable&lt;IEnumerable&lt;XElement&gt;&gt; ordersList = GetXElement(doc);
  
                  foreach (var order in ordersList)
                  {
                      var order = new Order();
                      order.FullPath = url;
  
                      foreach (var field in order)
                      {
                          var name = (string)field.Attribute(&quot;name&quot;);
                          MapField(order, field, name);
                      }
  
                      orders.Add(order);
                  }
              }
          }
          return orders;
  }
  </code></pre>