public void WriteString(string str_sec, string str_key, string str_value) { int dest_idx; int tmp_idx; dest_idx = FindSec(str_sec); if (dest_idx >= 0) { dest_idx = FindKey(str_key, dest_idx); if (dest_idx >= 0) //有 section 有 key { TmpList[dest_idx] = str_key + "=" + str_value; } else //有 section 沒 key { tmp_idx = FindSecLastIdx(str_sec); //TmpList.Insert(tmp_idx,str_key+"="+str_value); if (tmp_idx != TmpList.Count - 1) { TmpList.Insert(tmp_idx + 1, str_key + "=" + str_value); } else { TmpList.Add(str_key + "=" + str_value); } } } else //沒 section 沒 key { TmpList.Add("[" + str_sec + "]"); TmpList.Add(str_key + "=" + str_value); } }