Sunday, November 16, 2014

Method to check if theme exists

  /// <summary>
        /// Method to check if theme exists
        /// </summary>
        /// <param name="themeName"></param>
        /// <returns></returns>
        public static bool ThemeExists(string themeName)
        {
            bool hasTheme = false;
            try
            {
                System.IO.DirectoryInfo themeInfo = new System.IO.DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/App_Themes"));
                System.IO.DirectoryInfo[] dirInfo = themeInfo.GetDirectories();
                var theme = dirInfo.AsEnumerable().Where(dir => dir.Name == themeName);
                hasTheme = (theme != null && theme.Count() > 0);
            }
            catch
            {
            }
            return hasTheme;
        }

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...