public static void FillSection(ref string strSrcString, string strSectionName,string strNewValue) { int i = 0; int k = 0; int len = 0; string s = ""; i = strSrcString.IndexOf(strSectionName); if (i>0) { k = strSrcString.IndexOf("]", i); len = k - i + 2; strSrcString = strSrcString.Remove(i-1, len); int nSpace = len -Encoding.Default.GetByteCount(strNewValue.Trim().ToCharArray()); if (nSpace < 0) { return ; } string val = strNewValue + s.PadRight(nSpace); strSrcString = strSrcString.Insert(i-1, val); } }
{
int i = 0;
int k = 0;
int len = 0;
string s = "";
i = strSrcString.IndexOf(strSectionName);
if (i>0)
{
k = strSrcString.IndexOf("]", i);
len = k - i + 2;
strSrcString = strSrcString.Remove(i-1, len);
int nSpace = len -Encoding.Default.GetByteCount(strNewValue.Trim().ToCharArray());
if (nSpace < 0)
{
return ;
}
string val = strNewValue + s.PadRight(nSpace);
strSrcString = strSrcString.Insert(i-1, val);
}
}