c#

    [C#] ASP.NET API URL 대소문자 구분 안하게 설정

    ASP.NET API Routing Lowercase 수정 전 /api/Checkdb : success /api/checkdb : fail Routing 설정 # program.cs var builder = WebApplication.CreateBuilder(args); builder.Services.AddRouting(option => { option.LowercaseUrls = true; }); var app = builder.Build(); 수정 후 /api/Checkdb : success /api/checkdb : success

    [C#] ASP.NET API Cors 전체 허용

    ASP.NET API Cors 허용 UseCors 설정 http, https 허용 # Program.cs var app = builder.Build(); app.UseCors(x => { x.AllowAnyHeader(). AllowAnyMethod(). AllowAnyOrigin(). SetIsOriginAllowed(origin => true). WithOrigins("http://*"). WithOrigins("https://*"). AllowCredentials(); });

    [WPF, Telerik] RadGanttView - Event Container

    Event Container 일반적인 Task 표시 블럭 데이터 입력 XAML Code public ObservableCollection GanttTasks { get; set; } private void SetGantt() { // 2021-08-01 ~ 2021-08-02 // Title : Task 1 var task1 = new GanttTask(new DateTime(2021, 08, 01), new DateTime(2021, 08, 02), "Task 1"); // 2021-08-01 ~ 2021-08-03 // Title : Task 2 var task2 = new GanttTask(new DateTime(2021, 08, 01), new DateTime(2021, 08, 03), "Task..

    [C#] 압축 해제

    예제 public static bool ExtractZip(string filePath, string fileName, bool overwriting) { try { using (ZipArchive arch = ZipFile.Open(Path.Combine(filePath, fileName), ZipArchiveMode.Update, Encoding.UTF8)) { IReadOnlyCollection zipList = arch.Entries; foreach (ZipArchiveEntry zipItem in zipList) { // 간혹 파일명을 잘못 읽을 경우, 파일명에 ?가 포함되어 Exception이 발생할 수 있음. // ? 제거 작업 zipItem.ExtractToFile(Path.Combine(..

    [C#] EUC-KR Encoding 추가

    한글 깨짐 현상 발생 시 C#에서 간혹 한글이 깨질 경우 EUC-KR로 인코딩을 해줘야 하지만 기본 탑재가 되어 있지 않아 추가 작업 필요 예제 public static Encoding EUCKREncoding() { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding euckr = Encoding.GetEncoding(949); return euckr; } //EUCKREncoding 함수 직접 호출 public static main(){ StreamReader sr = new StreamReader("./test.txt",EUCKREncoding()); sr.close(); } 테스트 환경 .NET 5 Console 추가 -..

    [C#] bat 파일 실행할 때 로그를 Listbox에 넣기

    12345678910111213141516171819202122 private void thread_bat(ProcessStartInfo psi, string fileName, string filePath) { //filePath : 파일 전체 주소 //fileName : 파일 이름 (Listbox 표시를 위해 추가) //psi : ProcessStartInfo 지정 psi.FileName = filePath; //psi.Arguments = @"Test.bat"; psi.RedirectStandardOutput = true; psi.UseShellExecute = false; Process proc = Process.Start(psi); while (true) { string txt = proc.Sta..

    [C#] Thread에 값 전달하기

    Thread th = new Thread(() => functionName(param1, param2, param3) );12345Thread th1 = new Thread(() => api_load("String1","String2", chart1,label9));th1.Start(); Thread th2 = new Thread(() => api_load("String1","String2", chart2,label10));th2.Start();Colored by Color Scriptercs

    [C#] mysql 사용하기

    아래 사이트에서 mysql-connector 다운로드 https://downloads.mysql.com/archives/c-net/ Operation System : .Net & Mono 선택Version은 본인이 원하는 것으로 선택. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657using MySql.Data.MySqlClient;using MySql.Data;using System.Data;using System; namespace sports{ class test { //Insert, Delete, Update 사용 static void writefunc() ..

    [C#] 웹 파싱 (WebClient)

    1234567891011121314151617181920212223242526272829303132333435using System.Text;using System.Net; namespace test{ class test { static void testfunc() { /* * dom : html 저장 변수 * wc.DownloadString("url") : url의 html 코드를 불러옴. * wc.Dispose(); : WebClient 메모리 해제; * wc.Encoding : 한글 깨짐 방지를 위해 Encoding.UTF8 지정 */ WebClient wc = new WebClient(); wc.Encoding = Encoding.UTF8; string dom = wc.DownloadString(..