본문 바로가기

프로그래밍/C#24

[C#] Txt 파일에 한글을 읽거나 쓸 때 깨진다면? string textValue = System.IO.File.ReadAllText(path); // 읽을 때 한글이 깨짐 string textValue = System.IO.File.ReadAllText(path, Encoding.Default); // 안 깨짐 System.IO.File.WriteAllText(savePath, textValue); // 파일 쓸 때 한글이 깨짐. System.IO.File.WriteAllText(savePath, textValue, Encoding.Default); // 파일 쓸 때 깨지지 않음. Encoding.Defaul를 해주면 안깨진다. 진짜다. 2021. 3. 16.
[C#] 갑자기 삭제된 개체에 액세스 할 수 없습니다 라는 에러가 발생한 경우 나 같은 경우에는 public partial class Form1 : Form -> 맨 윗줄에 있는 코드. 이 코드 전에 다른 코드를 적어서 발생한 문제였다. 코드를 옮기니까 해결되었다. 2021. 3. 16.
[C#] Delay 함수. Thread Sleep 대신 쓸만함. www.bluene.net/blog/550 블루네군 블로그 :: C# Delay 함수 www.bluene.net 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 private void button1_Click(object sender, EventArgs e) { Delay(1000); MessageBox.Show("1초후에 메세지박스"); Delay(3000); MessageBox.Show("3초후에 메세지박스"); Delay(5000); MessageBox.Show("5초후에 메세지박스"); } /// /// Delay 함수 MS /// /// (단위 : MS) /// private static DateTi.. 2021. 3. 16.
[C#] File Exist 문서내에 파일이 존재하는지 docs.microsoft.com/ko-kr/dotnet/api/system.io.file.exists?view=net-5.0 File.Exists(String) 메서드 (System.IO) 지정된 파일이 있는지를 확인합니다.Determines whether the specified file exists. docs.microsoft.com MSDN에 되게 잘 나와있다. private void button1_Click(object sender, EventArgs e) { string curFile = @textBox1.Text; //if (Directory.Exists(curFile)) //폴더를 찾고싶을때 if(File.Exists(curFile)) // 파일을 찾고싶을때 MessageBox.Show(".. 2021. 3. 16.
[c#] new Form 생성, 새로운 폼 만들기 korbear.tistory.com/entry/C-%EB%B2%84%ED%8A%BC-%ED%81%B4%EB%A6%AD%EC%8B%9C-%ED%8F%BCform%EC%B6%94%EA%B0%80-%EC%83%88%EC%B0%BD-%EB%9D%84%EC%9A%B0%EA%B8%B0 C# 버튼 클릭시 폼(form)추가, 새창 띄우기 기존 폼에서 추가 폼을 불러오도록 하겠습니다. 우선 기본 winform을 만들어두고 프로젝트 -> 새 항목 추가 Windows Forms -> 양식(Windows Forms) 두 개의 form 준비 후 form2 호출하기 위해 버튼을 만들어 줍.. korbear.tistory.com private void button1_Click(object sender, EventArgs e) { .. 2021. 3. 16.
[C#] 텍스트파일 Read, Write, Replace 등등 infodbbase.tistory.com/113 C# Text File Read ( 텍스트 파일 읽기, 파일 읽기 ) 안녕하세요, 이번 포스팅은 C# 에서 Text 파일 읽기 관련 하여 정리 하였습니다. 1. 텍스트 파일 전체 내용 읽기 : 텍스트 파일의 내용 전체를 한번에 읽어 옵니다 * 코드 확인 // 읽어올 text file 의 infodbbase.tistory.com 076923.github.io/posts/C-22/ C# 강좌 : 제 22강 - 텍스트파일 읽기 쓰기 | 076923 읽기(Read Text) 076923.github.io infodbbase.tistory.com/114 C# Text File Write ( 텍스트 파일 쓰기 ) 안녕하세요, 이번 포스팅은 C# 에서 Text 파일 쓰.. 2021. 3. 16.