| CSVファイルを読み込む |
| StreamReader sr = StreamReader.Null; try { // テキストファイルを開く string sFileName = Application.StartupPath + "\\Data.csv"; sr = new StreamReader(sFileName, System.Text.Encoding.GetEncoding("Shift_JIS")); // ファイルの最終行までループ while (sr.Peek() != -1) { // カンマ区切り文字を配列に代入 string[] sSource = sr.ReadLine().Split(','); for (int iCount = 0; iCount < sSource.Length; iCount++) { // 出力ウィンドウに表示 Debug.WriteLine(sSource[iCount]); } } // ファイルを閉じる sr.Close(); } catch(IOException) { // エラー処理 } finally { // ファイルが開いていれば閉じる if (sr != StreamReader.Null) { sr.Close(); } } |