C#

[C#]디렉토리에 저장된 파일명을 문자 배열로 가져오기 예제

선영아 사랑해 2016. 1. 28. 09:49


디렉토리에 저장된 파일명을 읽어와서 처리해야 하는 경우가 종종 발생을 합니다.


그럴때 편하게 사용 할 수있는 예제코드이오니 참고해보세요.



using System.IO;


private void button1_Click(object sender, EventArgs e)
{
    string[] fileList = GetFile(Application.StartupPath);
}

private string[] GetFile(string dirPath)
{
    return Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories);
}