반응형
텍스트 파일의 끝에 텍스트를 추가하는 방법입니다.
File 클래스에 파일 끝에 텍스트를 추가 할 수 있는 여러 함수가 존재하는데 간단하게 추가해보도록 하겠습니다.
[함수]
※ 자세한 내용은 아래의 링크를 참조하세요.
https://docs.microsoft.com/ko-kr/dotnet/api/system.io.file.appendalltext?view=net-5.0
File.AppendAllText 메서드 (System.IO)
지정된 문자열을 파일에 추가합니다. 파일이 아직 없으면 만듭니다.Appends the specified string to the file, creating the file if it does not already exist.
docs.microsoft.com
[코드]
using (StreamWriter sw = File.AppendText(@"D:\test.txt"))
{
sw.WriteLine("");
sw.WriteLine("------------------------------------------------------------------------");
sw.WriteLine("파일 끝에 쓰기 테스트");
sw.WriteLine("------------------------------------------------------------------------");
}
반응형
'.Net' 카테고리의 다른 글
Visual Studio의 솔류션내 NuGet 설치 패키지 다른 프로젝트에 참조 적용하기 (0) | 2021.04.28 |
---|---|
C# DateTime Format (0) | 2021.04.27 |
C#에서 NSoup을 이용한 HTML 파싱하기 (0) | 2021.04.06 |
C# - DataGridView의 Column 높이 변경하기 (1) | 2021.02.26 |
C# 이미지(Bitmap) 회전하기 (0) | 2021.02.10 |
댓글