By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

API to get all themes from APP_Themes ?

P: n/a
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
Jan 30 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Good Aftrenoon,

I'm afraid System.IO is the only friend. You can save some time by looking
at Page class code (here you'll find excellent utility
http://www.aisto.com/roeder/dotnet/)
--
Milosz
"WT" wrote:
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
Jan 30 '07 #2

P: n/a
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[i] = Path.GetFileName(themes[i]);

// cache the array

CacheDependency dep = new CacheDependency(themesDirPath);

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

return themes;

}

}

JJ

"WT" <WT@newsgroups.nospamwrote in message
news:uz**************@TK2MSFTNGP04.phx.gbl...
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

Jan 30 '07 #3

P: n/a
WT
Thanks.

CS
"JJ" <ab*@xyz.coma écrit dans le message de news:
eR*************@TK2MSFTNGP02.phx.gbl...
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[i] = Path.GetFileName(themes[i]);

// cache the array

CacheDependency dep = new CacheDependency(themesDirPath);

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

return themes;

}

}

JJ

"WT" <WT@newsgroups.nospamwrote in message
news:uz**************@TK2MSFTNGP04.phx.gbl...
>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


Jan 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.