Exemple #1
0
    /// <summary>
    /// 根据键获得值数组
    /// </summary>
    /// <param name="strKey">键</param>
    /// <returns>值数组</returns>
    //public string[] GetPropertiesArray(string strKey)
    //{
    //    string strResult = string.Empty;
    //    string str = string.Empty;
    //    sr.BaseStream.Seek(0, SeekOrigin.End);
    //    sr.BaseStream.Seek(0, SeekOrigin.Begin);
    //    while ((str = sr.ReadLine()) != null)
    //    {
    //        if (str.Substring(0, str.IndexOf('=')).Equals(strKey))
    //        {
    //            strResult = str.Substring(str.IndexOf('=')+1);
    //            break;
    //        }
    //    }
    //    return strResult.Split(',');
    //}

    public static String readProperty(String baseName, String propertyName)
    {
        String propertyValue = null;
        String filePath = AppDomain.CurrentDomain.BaseDirectory + "properties\\" + baseName + ".properties";
        PropertyReader pr = new PropertyReader(filePath);
        
        propertyValue = pr.GetPropertiesText(propertyName);
        pr.Close();

        return propertyValue;

    }