Reputation:
How should i do to create yyyy/mm/dd directory easy?
mysite.com/blog**/2009/01/01/**hello-world.aspx!
Upvotes: 0
Views: 2895
Reputation: 25844
A variation on Jeff's answer:
String foo = "mysite.com/blog/" + DateTime.Now.ToString("yyyy\/mm\/dd") + "/hello-world.aspx";
Upvotes: 0
Reputation: 57568
Use the Uri class to combine the url together and use / to escape the \ character to be explicit rather than the cultural date seperator.
Uri oSiteBase = new Uri("http://mysite.com/blog");
Uri oSiteDay = new Uri(oSiteBase, DateTime.Now.ToString("yyyy\/MM\/dd"));
Upvotes: 0
Reputation: 20053
String.Format(CultureInfo.InvariantCulture,
"mysite.com/blog**/{0:yyyy/MM/dd}/**hello-world.aspx",
DateTime.Now)
Will get you the date. You can add more parameters to it to get it just right.
Upvotes: 9