public static void printLogID(string strID, [CallerMemberName] string functionName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int lineNumber = 0) { if (Notice != null) { try { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); string strMSG = resManager.GetString(strID); string fileName = Path.GetFileName(sourceFilePath); strMSG = fileName + ", " + lineNumber + ", " + functionName + " : " + strMSG; Notice(EMOutputTarget.LOG_FILE, strMSG); } catch (Exception ex) { MessageBox.Show("There are no Language resource files.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); CNotice.printLog(ex.Message); } } }
public bool isExistDirectory(string dirPath) { try { return(Directory.Exists(dirPath)); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public bool isExistFile(string fileFullPathName) { try { return(File.Exists(fileFullPathName)); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public bool setCurrentDirectory(string strDirectory) { try { System.IO.Directory.SetCurrentDirectory(strDirectory); return(true); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
/// <summary> /// - 프로세스의 갯수를 확인한다. /// - Window Name 이 아니라 Process Name 을 파라메터로 넘겨야 한다. /// </summary> /// <param name="strProcessName"></param> public static int getProcessesCount(string strProcessName) { try { Process[] processList = Process.GetProcessesByName(strProcessName); return(processList.Length); } catch (Exception ex) { CNotice.printLog(ex.Message); return(0); } }
public static void noticeWarningID(string strID) { try { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); string strTitle = resManager.GetString("W"); string strMSG = resManager.GetString(strID); // DataSet 에 \n 이 들어가서 \\n 이 되기 때문에 다시 복원해야 개행이 된다. strMSG = strMSG.Replace("\\n", "\n"); MessageBox.Show(strMSG, strTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show("There are no Language resource files.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); CNotice.printLog(ex.Message); } }
public bool copyDirectory(string sourDirPath, string destDirPath) { try { if (false == isExistDirectory(sourDirPath)) { CNotice.printLog("존재하지 않는 " + sourDirPath + " 를 복사하려고 합니다."); return(false); } if (!Directory.Exists(destDirPath)) { createDirectory(destDirPath); } string[] files = Directory.GetFiles(sourDirPath); string[] dirs = Directory.GetDirectories(sourDirPath); foreach (string file in files) { string name = Path.GetFileName(file); string dest = Path.Combine(destDirPath, name); File.Copy(file, dest); } // foreach 안에서 재귀 함수를 통해서 폴더 내부의 폴더 및 파일 복사 진행한다. foreach (string dir in dirs) { string name = Path.GetFileName(dir); string dest = Path.Combine(destDirPath, name); copyDirectory(dir, dest); } return(true); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public bool deleteFile(string strFileFullPathName) { try { if (false == isExistFile(strFileFullPathName)) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printLog(resManager.GetString("TIAA2") + strFileFullPathName + resManager.GetString("_TDNE")); return(false); } File.Delete(strFileFullPathName); return(true); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public List <string> getFileList(string dirPath) { try { if (false == isExistDirectory(dirPath)) { CNotice.printLog("존재하지 않는 " + dirPath + " 의 내부 파일정보를 얻으려고 합니다."); return(null); } List <string> lsFiles = new List <string>(); lsFiles = Directory.GetFiles(dirPath).Cast <string>().ToList(); return(lsFiles); } catch (Exception ex) { CNotice.printLog(ex.Message); return(null); } }
public bool deleteDirectory(string dirPath) { try { if (false == isExistDirectory(dirPath)) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printLog(resManager.GetString("TIAA2") + dirPath + resManager.GetString("_TDNE")); return(false); } Directory.Delete(dirPath, true); return(true); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
/// <summary> /// - 메모리에 하나라도 해당 이름의 Process 가 동작하고 있는지 확인한다. /// </summary> /// <param name="strProcessName"></param> public static bool isRunProcesses(string strProcessName) { try { Process[] processList = Process.GetProcessesByName(strProcessName); if (processList.Length == 0) { return(false); } else { return(true); } } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public bool copyFile(string sourceFileFullPathName, string destFileFullPathName, bool bOverWrite = false) { try { string destDirName = Path.GetDirectoryName(destFileFullPathName); if (false == isExistFile(sourceFileFullPathName)) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printLog(resManager.GetString("TIAA") + sourceFileFullPathName + resManager.GetString("_TDNE")); return(false); } if (!isExistDirectory(destDirName)) { createDirectory(destDirName); } // 이미 파일이 존재하면 복사를 취소 한다. if (true == isExistFile(destFileFullPathName) && bOverWrite == false) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printLog(resManager.GetString("TIAA4") + destFileFullPathName + resManager.GetString("_TDNE")); return(false); } File.Copy(sourceFileFullPathName, destFileFullPathName, bOverWrite); return(true); } catch (Exception ex) { CNotice.printLog(ex.Message); return(false); } }
public void addMessage(string message) { message = ">> " + message; try { ListViewItem item = new ListViewItem(message); this.Items.Add(item); if (this.Items.Count > iLimitLine) { this.Items.Remove(this.Items[0]); } // listview 의 View 속성을 Detail 로 하고 하나의 해더를 추가해야 한다 this.TopItem = this.Items[this.Items.Count - 1]; } catch (Exception ex) { CNotice.printLog(ex.Message); } }
public List <string> getDirectoryList(string dirPath) { try { if (false == isExistDirectory(dirPath)) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printLog(resManager.GetString("TIAA3") + dirPath + resManager.GetString("_DITD")); return(null); } List <string> lsDirs = new List <string>(); lsDirs = Directory.GetDirectories(dirPath).Cast <string>().ToList(); return(lsDirs); } catch (Exception ex) { CNotice.printLog(ex.Message); return(null); } }
/// <summary> /// - 동일 이름의 Process 를 메모리에서 모두 삭제한다. /// </summary> /// <param name="strProcessName"></param> public static void killProcesses(string strProcessName, int idException = 0) { try { int nCount = 0; int nLimitProcessCount; int indexProcess = 0; // 예외 프로세스가 있는 경우는 한개의 프로세스는 남긴다. if (idException == 0) { nLimitProcessCount = 0; } else { nLimitProcessCount = 1; } Process[] processList = null; const int TIME_STEP_ms = 100; do { processList = Process.GetProcessesByName(strProcessName); if (processList.Length > 0) { // 예외 프로세스가 있는 경우는 예외 프로세스를 제외한다. if (idException == 0) { processList[indexProcess].Kill(); } else { if (processList[indexProcess].Id == idException) { // 예외 프로세스는 0번 인덱스로 남겨두고 다음 인텍스들을 삭제하기 위해 1로 변경한다. indexProcess = 1; } else { processList[indexProcess].Kill(); } } } // 프로세스가 사라지는 시간을 확보한다. Thread.Sleep(TIME_STEP_ms); // 무한 루프를 방지한다. if (nCount > 50) { return; } nCount++; // 프로세스를 Kill 할때 processList.Length 가 바로 변경되지 않아서 while 비교전에 다시 processList 를 얻어온다 // 중복 호출되는 아쉬움이 있다. processList = Process.GetProcessesByName(strProcessName); } while (processList.Length > nLimitProcessCount); } catch (Exception ex) { CNotice.printLog(ex.Message); return; } }