/// <summary> /// 특정 행의 구분자로 나누어지는 문자열들을 얻어온다 /// </summary> /// <param name="strCSVFileFullName"></param> /// <param name="listLowString">행의 여러 문자열을 담는 리스트</param> /// <param name="iLowNumber">행의 번호 (1부터 ~ , 인덱스 아님)</param> /// <returns></returns> public bool readCSVRowString2(string strCSVFileFullName, ref List <string> listLowString, int iLowNumber) { string[] arrayAllLine; int nLineCount = 0; if (iLowNumber < 1) { CNotice.printTrace("Low Number have to be greater than 1."); return(false); } // 이전에 사용하던 List 데이터를 우선 삭제한다. listLowString.Clear(); try { if (false == m_manageFile.isExistFile(strCSVFileFullName)) { ResourceManager resManager = ResourceManager.CreateFileBasedResourceManager("LanguageResource", Application.StartupPath, null); CNotice.printTrace(resManager.GetString("TIAA5") + strCSVFileFullName + resManager.GetString("_TDNE")); return(false); } arrayAllLine = File.ReadAllLines(strCSVFileFullName); // string Array 를 List 에 담는다. foreach (string strLine in arrayAllLine) { nLineCount++; //특정 행을 제외한다. 주로 상단 제목줄을 제외할 때 사용한다. if (nLineCount == iLowNumber) { CParsing.getStringInAllLine(strLine, ref listLowString, ','); } } } catch (Exception ex) { CNotice.printTrace(ex.Message); return(false); } return(true); }
//Marerial 데이터를 읽어온다 public bool readMaterialMagnetData(string strFileFullName, string strMaterialName, ref double dMu, ref double dHc) { List <string> listString = new List <string>(); string strLine, strName, strTemp, strData; char[] separetor = { '=' }; int nIndex; try { if (false == m_manageFile.isExistFile(strFileFullName)) { CNotice.printTraceID("TMFD"); return(false); } List <string> listMaterialNames = new List <string>(); readMaterialNames(strFileFullName, ref listMaterialNames); if (listMaterialNames.Contains(strMaterialName) == false) { CNotice.printTrace("존재하지 않은 영구자석의 특성값을 얻으려고 하고 있다."); return(false); } getAllLines(strFileFullName, ref listString); // 다음 행을 사용하는 경우도 있어서 foreach 를 사용하지 않았다. for (int i = 0; i < listString.Count; i++) { strLine = listString[i]; // keyword 앞을 \t 를 제거한다. strLine = strLine.Trim(); if (strLine == "$begin \'MaterialDef\'") { strName = listString[i + 1]; strName = strName.Trim(); // 이름 얻기 nIndex = strName.IndexOf("'"); strTemp = strName.Substring(nIndex + 1); nIndex = strTemp.IndexOf("'"); strTemp = strTemp.Remove(nIndex); // BH 곡선 수집을 시작한다. if (strTemp == strMaterialName) { strData = listString[i + 2]; CParsing.getDataInLine(strData, ref dMu, '=', 2); strData = listString[i + 3]; CParsing.getDataInLine(strData, ref dHc, '=', 2); } } } } catch (Exception ex) { CNotice.printTrace(ex.Message); CNotice.printTraceID("AETT"); return(false); } return(true); }