protected void Page_Load(object sender, EventArgs e)
{
// Specify the destination folder
string directory = @"C:\Windows\Microsoft.NET\Framework\v3.5";
IterationFile(directory);
}
private void IterationFile(string path)
{
DirectoryInfo di = new DirectoryInfo(path);
// Output the current directory.
Response.Write(di.ToString() + "<br />");
// Gets all the files in the current directory
FileInfo[] fiArray = di.GetFiles();
// Each cycle 1 A file
for (int i = 0; i < fiArray.Length; i++)
{
Response.Write(fiArray[i].ToString() + "<br/>");
}
// At the end of each directory, write 1 A blank line.
Response.Write("----------------------------------------------------------------------------<br/>");
// Gets all subdirectories in the current directory
DirectoryInfo[] diArray = di.GetDirectories();
// Each cycle 1 A directory
for (int j = 0; j < diArray.Length; j++)
{
IterationFile(diArray[j].FullName);
}
}