Code
public static void CreateCorporateStructure(String _foldername)
{
try
{
Type typeOfclsConstant = typeof(clsConstant);
FieldInfo[] objFieldInfo = typeOfclsConstant.GetFields();
foreach (FieldInfo fi in objFieldInfo.Where(fi => fi.Name.Contains("_POSTFIX")))
{
Directory.CreateDirectory(HttpContext.Current.Server.MapPath("../" + clsConstant.COMPANY_PREFIXURL) + _foldername + Convert.ToString(fi.GetValue(null)).Substring(0, Convert.ToString(fi.GetValue(null)).Length - 1));
}
}
catch (Exception ex)
{
throw ex;
}
}
Explaination
- foreach (FieldInfo fi in objFieldInfo.Where(fi => fi.Name.Contains("_POSTFIX"))) is used to fetch number of fields from static class where variable name is ending with "_POSTFIX".
- fi.GetValue(null)) which give the static value for field or variable.
No comments:
Post a Comment