C# Text File Read ( 텍스트 파일 읽기, 파일 읽기 )
안녕하세요, 이번 포스팅은 C# 에서 Text 파일 읽기 관련 하여 정리 하였습니다. 1. 텍스트 파일 전체 내용 읽기 : 텍스트 파일의 내용 전체를 한번에 읽어 옵니다 * 코드 확인 // 읽어올 text file 의
infodbbase.tistory.com
C# 강좌 : 제 22강 - 텍스트파일 읽기 쓰기 | 076923
읽기(Read Text)
076923.github.io
C# Text File Write ( 텍스트 파일 쓰기 )
안녕하세요, 이번 포스팅은 C# 에서 Text 파일 쓰기에 관련 하여 정리 하였습니다. hello. This posting content is text file writing with c# programming. 1. Text File 에 Text 입력 ( 파일 새로 생성 ) : Tex..
infodbbase.tistory.com
docs.microsoft.com/ko-kr/dotnet/csharp/how-to/modify-string-contents
문자열 내용 수정 방법 - C# 가이드
C#에서 기존 문자열 콘텐츠를 수정하여 새 문자열 개체를 반환하는 다양한 기술의 예제를 검토합니다.
docs.microsoft.com
최종적으로 merge한 코드이다.
private void button1_Click(object sender, EventArgs e)
{
string source = "The mountains are behind the clouds today.";
// Replace all occurrences of one char with another.
var replacement = source.Replace(' ', '_');
Console.WriteLine(source);
Console.WriteLine(replacement);
string path = @"C:\Users\jh\Desktop\test.txt";
string[] textValue = System.IO.File.ReadAllLines(path); // 한줄 씩 읽기
//string textValue = System.IO.File.ReadAllText(path); // 모든줄 읽기
if (textValue.Length>0)
{
for (int i = 0; i < textValue.Length; i++)
{
textBox1.Text = textValue[i];
}
}
//string savePath = @"c:\test.txt";
//string textValue = "텍스트 파일 입력";
//System.IO.File.WriteAllText(savePath, textValue, Encoding.Default);
}
잘 동작한다.
Using System.IO;
를 추가해주어야한다.
'프로그래밍 > C#' 카테고리의 다른 글
[C#] File Exist 문서내에 파일이 존재하는지 (1) | 2021.03.16 |
---|---|
[c#] new Form 생성, 새로운 폼 만들기 (0) | 2021.03.16 |
[C#] opendialog 함수, OFD 간단한 사용법 (0) | 2021.03.16 |
[C#] 현재 경로, user 경로 등 유용한 경로 모음 (0) | 2021.03.16 |
[C#] 파일이름 변경하기 (0) | 2021.03.16 |
댓글