Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 데이터베이스
- xml
- 기초
- SQL
- dll
- 인스톨
- 파라미터
- Visual Studio 2005
- Delphi
- WIN32 SDK
- 입문
- Firebird
- MySQL
- Visual Basic
- 예제
- vb
- winsock
- 시리얼 통신
- PostgreSQL
- 파이어버드
- 소니
- 셋업
- 초보
- c#
- 설치
- MFC
- SDK
- 델파이
- 문자열
- VB.NET
Archives
- Today
- Total
프로그래밍 노트
C#| 지정 디렉토리 밑의 파일명 가져오는 소스 예제 본문
using System;
using System.IO;
namespace DirectoryTest
{
class Program
{
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("디렉토리명 입력 안함");
return;
}
// 지정 디렉토리의 유무 확인
if (!Directory.Exists(args[0]))
{
Console.WriteLine("찾는 디렉토리 없음");
return;
}
DirectoryInfo dir = new DirectoryInfo(args[0]);
FileInfo[] files = dir.GetFiles();
// foreach 배열의 갯수를 모를 때, 모든 배열만큼 돈다.
foreach (FileInfo file in files)
{
// {0,-32} 자리 32칸 확보
// {1,16:N0} 16칸을 확보하여 소숫점 밑은 제거(뒷자리로 정렬)
Console.WriteLine("{0,-32} {1,16:N0} {2}",
file.CreationTime, file.Length, file.Name);
}
Console.ReadLine();
}
}
}
Comments