//aspx.cs file
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 trash : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<table style='width: 10px; height: 10px; margin-left:100px'>");
foreach(var directory in new DirectoryInfo("C:\\Users\\naresh\\Documents\\Visual Studio 2010\\WebSites\\CMANAGER").GetDirectories())
{
Response.Write( "<tr>");
Response.Write("<td><a href= view4.aspx?folder="+ directory.Name + "> "+ directory.Name +"</a></td>");
Response.Write("</tr>");
}
Response.Write("</table>");
}
}
With this code I’m listing all directories in the given directory with hyperlinks.So,If I click on the hyperlink now I should list all the files in the Particular directory in a separate page.But I’m having problem in giving Dynamic path based on the hyperlink clicked.
Please help me in this regard.
Thank you..
I think you want to use directory.FullName for the hyperlink. You many need to url encode it and then decode it on the new page when you read it off the query string.
On view4.aspx after reading the folder off the query string, create a directory info object again and iterate over the results of directory.GetFiles()
Here is a link to the DirectoryInfo class for more information
http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx