API to get all themes from APP_Themes ?

W

WT

Hello,

I need to list all available themes for a .NET app, is there any API in
..NET2 for this or should I explore the folder files using IO methods ?

Thanks for indication
CS
 
J

JJ

This is what I use to get an array of the name of all themes:



public static string[] GetThemes()

{

if (HttpContext.Current.Cache["SiteThemes"] != null)

{

return (string[])HttpContext.Current.Cache["SiteThemes"];

}

else

{

string themesDirPath = HttpContext.Current.Server.MapPath("~/App_Themes");

string[] themes = Directory.GetDirectories(themesDirPath);

for (int i = 0; i <= themes.Length - 1; i++)

themes = Path.GetFileName(themes);

// cache the array

CacheDependency dep = new CacheDependency(themesDirPath);

HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);

return themes;

}

}



JJ
 
W

WT

Thanks.

CS
JJ said:
This is what I use to get an array of the name of all themes:



public static string[] GetThemes()

{

if (HttpContext.Current.Cache["SiteThemes"] != null)

{

return (string[])HttpContext.Current.Cache["SiteThemes"];

}

else

{

string themesDirPath = HttpContext.Current.Server.MapPath("~/App_Themes");

string[] themes = Directory.GetDirectories(themesDirPath);

for (int i = 0; i <= themes.Length - 1; i++)

themes = Path.GetFileName(themes);

// cache the array

CacheDependency dep = new CacheDependency(themesDirPath);

HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);

return themes;

}

}



JJ

WT said:
Hello,

I need to list all available themes for a .NET app, is there any API in
.NET2 for this or should I explore the folder files using IO methods ?

Thanks for indication
CS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top