Copy code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
///Specify Destination Folder
String directory = @ "C:\Windows\Microsoft.NET\Framework\v3.5";
Iterationfile (directory);
}
private void Iterationfile (string path)
{
DirectoryInfo di = new DirectoryInfo (path);
//outputs the current directory.
Response.Write (di. ToString () + "<br/>");
//Get all files in the current directory
fileinfo[] Fiarray = di. GetFiles ();
//loop each file
for (int i = 0; i < fiarray.length i++)
{
Response.Write (Fiarray[i]. ToString () + "<br/>");
}
//end of each directory, write a blank line.
Response.Write ("----------------------------------------------------------------------------<br/>");
//Gets all subdirectories in the current directory
directoryinfo[] Diarray = di. GetDirectories ();
//Loop each directory
for (int j = 0; J < Diarray.length; J + +)
{
Iterationfile (diarray[j]. FullName);
}
}