본문 바로가기

c#

[JSON] Newtonsoft.Json 을 이용한 json 문자 파싱 출처: http://alpha-i.tistory.com/21 요즘은 데이터 저장 방식을 XML 보다 json 을 더 많이 쓰는걸로 알고있는데요, 직접 split 이나 정규식을 사용하여 json 데이터를 파싱하는건 정말정말 귀찮아서 훨신 편한 라이브러리를 사용합니다.Newtonsoft.Json 은 NuGet 에서 Newton 만 쳐도 나옵니다. 혹은 첨부파일 참조해주시고 Newtonsoft.Json.Linq 도 참조해주시고 ( using Newtonsoft.Json.Linq; ) string json = @" { "car" : { "Name" : "Sonata" } , "test" : "abc" } " //json 문자열JObject jobj = JObject.Parse(json); //문자를 객체화 이렇.. 더보기
Image to Byte Array C# 출처: http://net-informations.com/q/faq/imgtobyte.html The following program first convert an Image to ByteArray and then convert that byteArray to Image and loads in a picture box. using System; using System.Drawing; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_C.. 더보기
Rich text box appender 출처: https://mail-archives.apache.org/mod_mbox/logging-log4net-user/200804.mbox/%3C658979.41804.qm@web80002.mail.sp1.yahoo.com%3E using System; using System.Windows.Forms; using System.Drawing; using log4net; using log4net.Core; using log4net.Appender; using log4net.Util; namespace log4net.Appender { //.. //.. Appends logging events to a RichTextBox //.. //.. //.. //.. RichTextBoxAppender appends.. 더보기
log4net TextBox Appender 출처: http://www.hind.pe.kr/1248 C#에서 TextBox에 log4net을 띄우기 위한 방법. TextBox가 위치한 Form의 생성자 안에서 TextBoxAppender.SetupTextBoxAppend 를 호출하면 된다.인자값으로는 Textbox 인스턴스와 PatternLayout에 넣는 PatternFormat 문자열만 넣으면 된다. TextBoxAppender.SetupTextBoxAppend(txtLogs, "%date{HH:mm:ss,fff} %-5level %-33logger - %message%newline"); namespace Logger { public class TextBoxAppender : AppenderSkeleton { static public void .. 더보기
Log4Net ScrollingTextBox 출처: http://www.claassen.net/geek/blog/2005/06/log4net-scrollingtextbox.html I use log4net for most of my apps. I did similar things in all the languages i’ve worked with. I just like having a way to verbosely spew information into the ether so that i could use for analysing code when something gest wonky without having to step through the code or go uncommenting loads of Console.Writeline() call.. 더보기
Academy of programmer - How to use NLog in WinForms app 더보기
LogString: A Simple C# 2 Application Event Logging Class 출처: https://www.codeproject.com/Articles/15364/LogString-A-Simple-C-Application-Event-Logging-C IntroductionWhen interfacing to real-world devices, it is typical to have one or more background processing tasks responsible for collecting data and/or controlling the devices. Monitoring these tasks can be done in a variety of ways, some of which can involve complex GUI components for status reporti.. 더보기
log관련 출처: https://stackoverflow.com/questions/2196097/elegant-log-window-in-winforms-c-sharp로그 수준에 따라 목록 상자에서 색상을 지원하며, RTF로 복사하기 위해 Ctrl + V와 Right-Click을 지원하고 다른 스레드에서 ListBox로 로깅을 처리합니다.ListBox에 보관 된 줄 수 (기본적으로 2000)와 생성자 오버로드 중 하나를 사용하여 메시지 형식을 재정의 할 수 있습니다. using System; using System.Drawing; using System.Windows.Forms; using System.Threading; using System.Text; namespace StackOverflow { public p.. 더보기
Log4Net 사용법 출처: http://drt0927.tistory.com/7?category=682501 log4net 사용 관련 참고 사이트 : http://hind.pe.kr/1199log4net 설정 관련 참고 사이트 : http://egloos.zum.com/empty79/v/2956254 C#에서 logging을 할때 손쉽고 편하게 사용할 수 있는 라이브러리를 소개하려한다.Log4Net이라는 라이브러리 이다.이 라이브러리는 log4j라는 java라이브러리에서 따온것이라고 알고있다. log4net에 대한 자세한 내용은 홈페이지를 참조 바랍니다.https://logging.apache.org/log4net/ 1. 사용 방법 - Nuget으로 Log4Net을 검색하면 아파치 log4net이 제일 상위에 나타난다 "설치.. 더보기
ini file 사용법 출처: http://drt0927.tistory.com/8?category=682501 C# 응용 프로그램을 만들다보면 설정 파일이 필요한 경우가 있다.이때 ini file을 사용하면 간편하다. 물론 xml로 된 config file도 있지만 ini file이 직관적이고 수정하기 편하다.구글링을 해보면 C#에서 ini파일을 다루는 여러 내용들이 있지만, 효율적으로 ini file을 관리하고 수정이 용이하게 설명된 내용이 없어 직접 만든 내용을 공유하려 한다.그렇다고 내가 만든게 짱짱맨 이런 의미는 아니다. ini file의 구성은크게 section과 key로 나뉜다. 예를 들면 [Database]Address="localhost"Id="root" [User]Name="홍길동"Age="29" 이런 ini .. 더보기