C#11 C# 파일 읽기와 쓰기 C# 의 기본 프로그램 중의 하나이다. using System; using System.IO; class program { public static void Main() { using (StreamWriter w = File.AppendText("log.txt")) { w.WriteLine("Test 1"); w.WriteLine("Test 2"); } using (StreamReader r = File.OpenText("log.txt")) { string line; while ((line = r.ReadLine()) != null) { Console.WriteLine(line); } } } } 위의 프로그램에 더하여서, 파일이 존재하는지 Check 하는 방법은 아래와 같다. public string p.. 2023. 2. 12. C# echo 프로그램 만들기 using System; class program { private static void Main(string[] args) { int c; int cnt = 0; while ((c = Console.Read()) != -1 ) { cnt++; Console.Write( (char) c ); } Console.Write( "\n" + cnt + " characters read.\n"); } } ---- 다음은 string 변수를 사용한 약간 다른 방법이다. using System; class program { private static void Main(string[] args) { int c; string s = ""; while ((c = Console.Read()) != -1 ) { s = s + .. 2021. 11. 12. C#으로 메모장(Notepad) 만들기 C#으로 메모장(Notepad) 만들기이다. 출처는 다음과 같다. 아래의 링크를 따라가면, Youtube 동영상에 만드는 방법이 나와 있다. https://foxlearn.com/articles/how-to-make-a-notepad-in-csharp-152.html Windows Forms: How to make a Notepad in C# How to Make a simple Notepad in C# Windows Form Application using MenuStrip, OpenFileDialog, SaveFileDialog, StreamReader, StreamWriter, TextBox, Button and Label foxlearn.com Code는 메인 폼에 대한 코드만 있다. public.. 2021. 9. 19. C# Windows Forms 항상 닫히지 않게 하기 C#에서 Winform으로 만든 프로그램의 창이 항상 열려져 있게 하는 방법이다. 아래와 같이 Form을 초기화하는 곳 아래에 같은 Source code 로 작성하여 놓는다. public Form1() { InitializeComponent(); this.MaximizeBox = false; this.MinimizeBox = false; this.TopMost = true; } 참고한 곳은 Stack overflow 이다. https://stackoverflow.com/questions/3025923/disabling-minimize-maximize-on-winform Disabling Minimize & Maximize On WinForm? WinForms have those three boxes in.. 2021. 9. 19. 이전 1 2 3 다음