본문 바로가기

Web_Application/C#

(50)
텍스트 파일에서 정규표현식 문자열 추출 using System; using System.Text.RegularExpressions; public class Program { public static void Main() { try { String text = "Reports\\20200225170617.csv"; Regex pattern = new Regex(@"([1-9][0-9]*)"); MatchCollection resultCollection = pattern.Matches(text); foreach(var item in resultCollection){ Console.WriteLine("{0}", item); } } catch(Exception ex) { Console.WriteLine(ex); } } }
tdes en/decrypt class public class TrippleDES { public string Encode(string str, string key, string iv) { byte[] keyByte = getKeyByteArray(key); byte[] ivByte = getKeyByteArray(iv); MemoryStream fin = new MemoryStream(Encoding.UTF8.GetBytes(str), false); MemoryStream fout = new MemoryStream(); fout.SetLength(0L); byte[] bin = new byte[100]; long rdlen = 0; long totlen = fin.Length; int len = 0; TripleDESCryptoService..
ERROR: should be excluded because its source file '' is under Windows System File Protection. (When Building MSI) Target File > right click > Properties > Execlude = true
[c#][linq][winform] combobox query foreach get index, value string selectValue = 저장된 값"; foreach (var item in {{combobox}}.Items.Cast().Select((value, index) => new { index, value })) { // item.value == selectValue 저장된 값 선택하기 if (item.value == selectValue) { {{combobox}}.SelectedIndex = item.index; break; } }
[c#][winform][Linq] 여러개의 콤보박스 선택 유무 체크하기 ComboBox cmb = this.Controls.OfType().Where(c => c.GetType() == typeof(ComboBox) && c.Name != {{콤보박스1}}.Name && c.Name != {{콤보박스2}}.Name && c.Name != {{콤보박스3}}.Name && c.SelectedIndex == 0).OrderBy(c => c.TabIndex).FirstOrDefault(); if (cmb != null) { MessageBox.Show("필수 항목을 선택해 주세요."); cmb.Focus(); return; }
[c#][winform] textbox 숫자만 입력 받기 private void textbox1_TextChanged(object sender, EventArgs e) { // 소숫점(.), 자리수(,)는 허용하고 기타 문자가 있으면 입력 초기화. 다른 특수문자를 허용하려면 숫자 뒤에 붙이기 if (Regex.IsMatch(textbox1.Text, "[^0-9.,]")){ textbox1.Text = ""; } }
[c#][winform] To Set Maximize / Minimize Button Enable/Disable form properties > MaximizeBox = True/False form properties > MinimizeBox = True/False
[regex][mssql] INSERT SELECT, SELECT expression /(INSERT\s+(.*?)|)SELECT\s+(.*?)\s*FROM\s+(.*?)\s*(WITH|)\(NOLOCK\)\s(WHERE\s(.*)\s*)?/g matches SELECT D.CN_COA FROM TPE_04C D (NOLOCK) WHERE D.C_COA = A.C_COA SELECT D.CN_COA FROM TPE_04C D WITH(NOLOCK) WHERE D.C_COA = A.C_COA SELECT D.CN_COA FROM TPE_04C AS D WITH(NOLOCK) WHERE D.C_COA = A.C_COA SELECT D.CN_COA FROM TPE_04C AS D WITH(NOLOCK) WHERE D.C_COA = A.C_COA GROUP BY D.CN_CO..