title: If File Directory is Empty C#
body: <p>So I'm building a console app that has a feature to list all files in a directory and I would like to tell it to display a message "Directory is empty" if there are no files in that folder.  My code is returning the folder contents properly but I can't get it to display my text message if the directory is empty, it's like it's ignoring the if statement.  Anybody have suggestions as to why it's not working?  Thanks!</p>
  
  <pre><code>        Console.WriteLine(" Displaying Contents of Write Directory: ");
          Console.WriteLine(" ---------------------------------------");
          Console.WriteLine();
  
          string[] filePaths = Directory.GetFiles(writeDir);
          for (int i = 0; i &lt; filePaths.Length; ++i)
          {
              if (i == 0)
              {
                  Console.WriteLine();
                  Console.WriteLine(" Directory is Empty!");
                  Console.WriteLine();
                  Console.ReadLine();
              }
              else
              {
                  string path = filePaths[i];
                  Console.WriteLine("File: " + System.IO.Path.GetFileName(path));
                  Console.WriteLine();
              }
          }
  </code></pre>