Mates, after having a hard time trying to implement a class to enumerate the how filesystem tree I give up triyng to make it work.
I have a textbox with a filepath. I want the user to be able to click and from a panel displaying a filesystem tree it could click and select the path.
Could you guys help me with that.
Just for you understand what I was doing this is the code:
try
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
Response.Write("<ul class=\"jqueryFileTree\" style=\"display: none;\">\n");
foreach (DriveInfo drive in allDrives)
{
if (drive.IsReady == true)
{
try
{
Response.Write("\t<li class=\"drive collapsed\"><a href=\"#\" rel=\"" + drive.ToString() + "\">" + drive.ToString() + "</a>\n");
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(drive.ToString());
DirectoryInfo[] directories = di.GetDirectories("*.*", SearchOption.AllDirectories);
Response.Write("<ul>");
foreach (System.IO.DirectoryInfo di_child in directories)
{
Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + drive + di_child.Name + "/\">" + di_child.Name + "</a>\n");
Response.Write("<ul>");
foreach (System.IO.FileInfo fi in di.GetFiles())
{
string ext = "";
if (fi.Extension.Length > 1)
{
ext = fi.Extension.Substring(1).ToLower();
}
Response.Write("\t<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + drive + fi.Name + "\">" + fi.Name + "</a></li>\n");
}
Response.Write("</ul></li>");
}
Response.Write("</ul></li>");
}
catch (UnauthorizedAccessException e)
{
Response.Write(e.Message);
continue;
}
catch (System.IO.DirectoryNotFoundException e)
{
Response.Write(e.Message);
continue;
}
catch (Exception e)
{
Response.Write(e.Message);
continue;
}
}
}
Response.Write("</ul>");
}
catch (Exception)
{
throw;
}