title: C# list of all files on disk - Error CS1503 Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'string[]'
body: <p>Good morning!</p>
  
  <p>I have a little problem with my program. This program should list all files on C: disk but it throw me following exceptions:</p>
  
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error   CS1503  Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable&lt;string&gt;' to 'string[]'  ConsoleApplication2 c:\users\aleš\documents\visual studio 2015\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs  15  Active
  </code></pre>
  
  <p>Please, can you help me? This is not my code so I really don't know what to do with it.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Security.Permissions;
  using System.Text;
  
  namespace ConsoleApplication2
  {
      class Program
      {
          static void Main(string[] args)
          {
              var paths = Traverse(@"C:\");
              File.WriteAllLines(@"C:\\test.txt", paths);
          }
  
          private static IEnumerable&lt;string&gt; Traverse(string rootDirectory)
          {
              IEnumerable&lt;string&gt; files = Enumerable.Empty&lt;string&gt;();
              IEnumerable&lt;string&gt; directories = Enumerable.Empty&lt;string&gt;();
              try
              {
                  // The test for UnauthorizedAccessException.
                  var permission = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, rootDirectory);
                  permission.Demand();
  
                  files = Directory.GetFiles(rootDirectory);
                  directories = Directory.GetDirectories(rootDirectory);
              }
              catch
              {
                  // Ignore folder (access denied).
                  rootDirectory = null;
              }
  
              if (rootDirectory != null)
                  yield return rootDirectory;
  
              foreach (var file in files)
              {
                  yield return file;
              }
  
              // Recursive call for SelectMany.
              var subdirectoryItems = directories.SelectMany(Traverse);
              foreach (var result in subdirectoryItems)
              {
                  yield return result;
              }
          }
      }
  }
  </code></pre>
  
  <p>Thank you so much!
  With regards,
  Aleš</p>