Im running a long process using ProgressBox, and in that process im using System.Web.HttpContext.Current.Server.MapPath() method, which throws exception because System.Web.HttpContext.Current is null, Is there any method to do same functionality?
You can use
HostingEnvironment.MapPath(string path)
Yes.
Sitecore.IO.FileUtil.MapPath(string path)
Maps a virtual file path to a physical file path.
Parameters path - A virtual file path.
Return Value The physical file path.
Remarks If the file path is blank, contains a backslash () or contains the string "://" the path itself is returned.
Example The following example returns the physical filename of the mydata.xml file in the data folder. Afterwards the filename variable holds a value like "c:\inetpub\wwwroot\default website\sitecore\data\mydata.xml".
string filename = FileUtil.MapPath("/sitecore/data/mydata.xml");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With