C# 에서 텍스트 파일 읽기
1. File 의 ReadAllText, ReadAllLines 사용
// 파일을 하나의 string으로 읽기
string text = System.IO.File.ReadAllText(@"d:\test.txt");
// 배열에 한라인씩 읽기
string[] lines = System.IO.File.ReadAllLines(@"d:\test.txt");
2. StreamReader Readline메서드 사용
string line;
System.IO.StreamReader file = new System.IO.StreamReader(@"d:\test.txt");
while((line = file.ReadLine()) != null)
{
}
file.Close();
'coding' 카테고리의 다른 글
스위프트 프로젝트 구성은 (1) | 2023.03.01 |
---|---|
C# Visual Studio 단축키 (4) | 2022.08.27 |
AutoCAD .NET Developer's Guide (0) | 2015.12.09 |