title: Listing Folders in a Directory using asp.net and C#
body: <p>.aspx file:</p>
  
  <pre><code>&lt;%@ Import Namespace="System.IO" %&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head id="Head1" runat="server"&gt;
  &lt;title&gt;Explorer&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>.CS file:</p>
  
  <pre><code> using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Web;
   using System.Web.UI;
   using System.Web.UI.WebControls;
   using System.IO;
  
  public partial class view2 : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
      string path = "~/";
      GetFilesFromDirectory(path);
  }
  
  private static void GetFilesFromDirectory(string DirPath)
  {
           try
           {
               DirectoryInfo Dir = new DirectoryInfo(DirPath);
               FileInfo[] FileList = Dir.GetFiles("*.*", SearchOption.AllDirectories);
               foreach (FileInfo FI in FileList)
               {
                   Console.WriteLine(FI.FullName);
               }
           }
           catch (Exception ex)
           {
                  Console.WriteLine(ex.Message);
           }
  }
  </code></pre>
  
  <p>I want to list the folders in a particular directory but it continuously showing blank page.Can anybody tell what's the problem in the code.</p>