[C#,닷넷, recursion, 재귀예제]파일,디렉토리 탐색, C#을 재귀호출을 이용한 디렉토리 탐색 예제 입니다.
using System;
using System.IO;
using System.IO;
class GetDir
{
public void Find(DirectoryInfo dir)
{
Console.WriteLine(dir.Name);
DirectoryInfo[] dirs = dir.GetDirectories();
if (dirs.Length < 1) return;
for(int i=0; i<dirs.Length; i++)
{
//Console.WriteLine(dirs[i].ToString());
Find(dirs[i]);
}
}
{
public void Find(DirectoryInfo dir)
{
Console.WriteLine(dir.Name);
DirectoryInfo[] dirs = dir.GetDirectories();
if (dirs.Length < 1) return;
for(int i=0; i<dirs.Length; i++)
{
//Console.WriteLine(dirs[i].ToString());
Find(dirs[i]);
}
}
public static void Main()
{
GetDir g = new GetDir();
DirectoryInfo dir = new DirectoryInfo(@"c:\");
g.Find(dir);
}
}
{
GetDir g = new GetDir();
DirectoryInfo dir = new DirectoryInfo(@"c:\");
g.Find(dir);
}
}
댓글 없음:
댓글 쓰기