This project is read-only.

Accessing and Reading files using Orchard api

Topics: Core, General, Writing modules
Jan 26, 2012 at 2:18 PM
Edited Jan 26, 2012 at 2:27 PM

I have a file containing a  list of countries (I was thinking of keeping them in App_Data) that I want to load into a static list in a model and was wondering what is the best way to do this using Orchard. I see there is an IAppDataFolder but am not sure how to use it. Or should I just use System.IO and map the virtual path?

i.e. How do I get the current path to App_Data?

Jan 26, 2012 at 4:59 PM

Have look at how Settings etc. access the App_Data folder. Personally, I just use Server.MapPath (did the same for a GeoIP spreadsheet)

Jan 26, 2012 at 5:23 PM

Great, thanks. I used Server.MapPath in the end.

Nov 5, 2013 at 11:37 PM
sorry to ask, but i am a newbie to orchard and I'm writing a module and I need to get the absolute path to a file in order to pass that as a parameter to a service class, could you please tell me how to use the Server.MapPath since is seems to have solved your problems
Nov 6, 2013 at 5:53 AM
You can get MapPath from the current HttpContext, which you can also get from WorkContext.