본문 바로가기

Web_Application/C#

(50)
[c#] 경과 시간을 표시할 때 String saveTempString = string.empty;DateTime tempDateTime = DateTime.Now; // 시작하는 위치 ... 처리 로직 TimeSpan diff = DateTime.Now - tempDateTime; saveTempString = string.Format("{0:hh\\:mm\\:ss}", diff); Console.WriteLine(saveTempString);
[c#] StreamWriter 로 텍스트 파일 생성/쓰기 StreamWriter 로 텍스트 파일 생성/쓰기 public static void SaveFile(string filePath, string saveData = null) { if (!File.Exists(filePath)) { using (StreamWriter sw = File.CreateText(filePath)) { sw.Write(saveData); sw.AutoFlush = true; } } else { using (StreamWriter sw = File.AppendText(filePath)) { sw.Write("\r\n" + saveData); sw.AutoFlush = true; } } } 참조 : StreamWriter MSDN
[Selenium] “IEDriverServer does not exist” error during running Selenium test with C# in Windows 7 System.Environment.SetEnvironmentVariable("webdriver.ie.driv‌​er", "c:\\Windows\\System32\\MicrosoftWebDriver.exe"); this.driver = new InternetExplorerDriver();%PATH%를 검색하는 방식이 아니라 직접 드라이버를 지정하는 방식으로 변경해야합니다. web driver download link
[Selenium] “chromedriver.exe does not exist” error during running Selenium test with C# in Windows 7 System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", "c:\\Windows\\System32\\chromedriver.exe");this.driver = new InternetExplorerDriver(); %PATH%를 검색하는 방식이 아니라 직접 드라이버를 지정하는 방식으로 변경해야합니다. web driver download link
[Selenium] Unexpected error launching Internet Explorer. Protected Mode must be set to the same value IE > 인터넷옵션> 보안 인터넷, 로컬인트라넷, 신회할 수 있는 사이트, 제한된 사이트 의 보호모드를 해제하고 IE 를 재시작 합니다.
[Selenium] Web Driver download link selenium release url 에서 web driver 를 download 할 수 없게 됐습니다. 아래 개발사 download 사이트에서 web driver 를 다운로드 하시기 바랍니다. chrome driver https://sites.google.com/a/chromium.org/chromedriver/downloads microsoft web driver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
[C#]제곱미터를 평으로 변환 /// /// 제곱미터를 평으로 변환 /// /// /// public string tranferSqaureMeterToPyeung(string squareMeter) { double tempSquareMeter = 0.0; string tempPyeung = "0"; try { tempSquareMeter = double.Parse(getRealNumber(squareMeter)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } tempPyeung = Math.Round((tempSquareMeter * pyeongValue), 2).ToString(); return tempPyeung; } getRealNumber 참조
[C#]문자열에서 실수부분만 추출 /// /// 문자열에서 실수부분만 추출 /// /// /// public string getRealNumber(string number) { string tempValue = "0"; try { Regex pattern = new Regex(@"[0-9]+(\.|\,)[0-9]+"); Match match = pattern.Match(number); tempValue = match.Value; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return tempValue; }