Using System;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using system.web
Namespace Pi_disease. Pianalysis
{
<summary>
Summary description of Readfilename
</summary>
public class Readfilename:ihttphandler
{
public void ProcessRequest (HttpContext context)
&NBSP ; {
//string FileName = "";
//string fileparent = "";
String strall = "[";
//-----------------------------------------------------
& nbsp //read parent node name
string Fileparent = GetFileName ();
string[] parentfile;
string strparent = "";
if (Fileparent.contains (', '))//parent node How many
&NBS P parentfile = Fileparent.split (', ');
else//on a
{
strparent = fileparent; parentfile = new String[1];
parentfile[0] = strparent;
}
for (int i = 0; i < Parentfile. Length; i++)
{
String strparentfile = "{\" text\ ": \" "+ parentfile[i] +" \ ", \" state\ ": \" closed\ ", \" children\ ": [";
Strall + = Strparentfile;
String strfile = "";
strfile = strfile + parentfile[i];
//-----------------------------------------------------
Read the second-level node name
String secondfile = GetFileName2 (strfile);
String[] filename2;
String strsecond = "";
if (secondfile. Contains (', '))//file name has multiple
filename2 = Secondfile. Split (', ');
else//is a
{
Strsecond = Secondfile;
filename2 = new String[1];
Filename2[0] = Strsecond;
}
for (int j = 0; J < filename2. Length; J + +)
{
String strsecondfile = "{\" text\ ": \" "+ filename2[j] +" \ ", \" state\ ": \" closed\ ", \" children\ ": [";
Strall + = Strsecondfile;
String strFile2 = "";
StrFile2 = StrFile2 + filename2[j];
//-----------------------------------------------------
Read the third-level node name
String thirdfile = GetFileName3 (strfile, strFile2);
String[] Filename3;
String strthird = "";
if (thirdfile. Contains (', '))//file name has multiple
Filename3 = Thirdfile. Split (', ');
else//is a
{
Strthird = Thirdfile;
Filename3 = new String[1];
Filename3[0] = Strthird;
}
for (int k = 0; k < Filename3. Length; k++)
{
String strthirdfile = "{\" text\ ": \" "+ filename3[k] +" \ "}";
if (k! = Filename3. LENGTH-1)
Strall + = Strthirdfile + ",";
Else
Strall + = Strthirdfile;
}
Strall + = "]}";
if (j! = filename2. LENGTH-1)
Strall + = ",";
}
Strall + = "]}";
if (i! = parentfile. LENGTH-1)
Strall + = ",";
}
Strall + = "]";
Context. Response.Write (Strall);
}
private String GetFileName ()
{
String sfilename = "";
String path = @ "X:\XX";
string[] aa = directory.getdirectories (path);
string[] FileName = new String[directory.getdirectories (path). Count ()];
for (int i = 0; i < directory.getdirectories (path). Count (); i++)
{
Filename[i] = Aa[i]. Substring (path. Count () + 1);
}
for (int i = 0; i < filename.length; i++)
{
if (i! = filename.length-1)
sFileName = sFileName + filename[i]. ToString () + ",";
Else
sFileName = sFileName + filename[i]. ToString ();
}
return sfilename;
}
private string GetFileName2 (String strfile)
{
String sfilename = "";
String path = @ "X:\XX\" + strfile + ""; @ "X:\XX\" path
string[] aa = directory.getdirectories (path);
string[] FileName = new String[directory.getdirectories (path). Count ()];
for (int i = 0; i < directory.getdirectories (path). Count (); i++)
{
Filename[i] = Aa[i]. Substring (path. Count () + 1);
}
for (int i = 0; i < filename.length; i++)
{
if (i! = filename.length-1)
sFileName = sFileName + filename[i]. ToString () + ",";
Else
sFileName = sFileName + filename[i]. ToString ();
}
return sfilename;
}
private string GetFileName3 (String strfile, String strfile2)
{
String sfilename = "";
DirectoryInfo folder = new DirectoryInfo (@ "X:\XX\" + strfile + "\ \" + Strfile2 + "");//directory named skins, placed under the software root
Information for the specified file under the looping folder
string[] FileName = new String[folder. GetFiles ("*.jpg"). Count ()];
for (int i = 0; i < folder. GetFiles ("*.jpg"). Count (); i++)
{
This is the assignment to the specified index in the array.
Filename[i] = folder. GetFiles ("*.jpg") [i]. Name;
}
for (int i = 0; i < filename.length; i++)
{
if (i! = filename.length-1)
sFileName = sFileName + filename[i]. ToString () + ",";
Else
sFileName = sFileName + filename[i]. ToString ();
}
return sfilename;
}
public bool IsReusable
{
Get
{
return false;
}
}
}
}
C # Read path folder name-folder name-file name