- 700 名前:デフォルトの名無しさん mailto:sage [2009/09/11(金) 18:16:47 ]
- File.ReadAllLinesの方が良くねえ?
ファイルを行ごとに取り扱うのにReadToEndで読む必要性が分からん。 string optionValue = ""; string[] lines = null; try { lines = File.ReadAllLines(args[0], Encoding.GetEncoding("Shift_JIS")) }catch{ lines = new string[0]; } foreach (string line in lines) { // 空行と先頭'#'のスキップ if ((line == String.Empty) || (line[0] == '#')) { continue; } //行をトークン分解 string[] toks = line.Split('='); if ((toks.Length == 2) && (toks[0] == args[1])) { optionValue = toks[1]; break; } } Console.Write(optionValue);
|

|