c#8 [C#] 특정일 이전 로그폴더 삭제하기 //using System; //using System.IO; //using System.Collections.Generic; //로그폴더명 형식 : yyyy-mm-dd string today = DateTime.Now.ToString("yyyy-MM-dd"); string upperPath = {로그 폴더경로}; //삭제 기준일자 설정 int deleteDays = 30; string targetDay = DateTime.Now.AddDays(-deleteDays).ToString("yyyy-MM-dd"); bool res = false; DirectoryInfo di = new DirectoryInfo(upperPath); //폴더 경로 미존재 시 종료 //폴더 경로 존재할 경우, 폴더 내 파일목록 .. 2024. 3. 29. [C#] 데이터 테이블(DataTable)의 열(Column) 데이터 추출 //using System; //using System.IO; //using System.Collections.Generic; DataTable dt = {데이터테이블 객체명}; string data = ""; foreach(DataRow row in dt.Rows) { string target = row[0].ToString(); //column index가 0에 해당하는 값을 문자열로 변환 if(data != "") { data += "\n" + target; } else { data += target; } } return data; //column index가 0인 값의 전체 데이터 2024. 3. 25. [C#] 파일명과 파일 생성일 정보를 활용하여 파일경로 찾기 //using System; //using System.IO; //using System.Collections.Generic; string today = DateTime.Now.ToString("yyyy-MM-dd"); string path = {폴더경로}; DirectoryInfo di = new DirectoryInfo(path); //폴더 내 하위폴더 모든 파일리스트 가져오기 string[] allFiles = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); string filePath = ""; string parseDate = ""; //찾고자하는 당일 생성파일이 위치한 파일경로 추출 foreach(string file in allF.. 2024. 3. 25. [C#] cmd 명령어 실행결과 추출 //using System; //using System.Collections.Generic; //using System.ComponentModel; //using System.Data; //using System.Diagnostics; //using System.Drawing; //using System.Linq; //using System.Text; //using System.Threading.Tasks; //using System.Windows.Forms; ProcessStartInfo cmd = new ProcessStartInfo(); Process process = new Process(); cmd.FileName = @"cmd"; cmd.WindowStyle = ProcessWindowStyl.. 2024. 3. 25. 이전 1 2 다음