Alternative to System.Web.HttpContext.Current when using ProgressBox
I am starting a long process using ProgressBox and in this process im using System.Web.HttpContext.Current.Server.MapPath () method which throws an exception because System.Web.HttpContext.Current is null, is there any method perform the same functions?
you can use
HostingEnvironment.MapPath(string path)
Yes.
Sitecore.IO.FileUtil.MapPath(string path)
Displays the path of the virtual file to the path of the physical file.
Parameters path - path to the virtual file.
Returned value The physical path to the file.
Remarks If the file path is empty, contains a backslash (), or contains the string ": //", the path is returned.
Example The following example returns the physical name of the file mydata.xml in the data folder. Subsequently, the filename variable stores a value similar to "c: \ inetpub \ wwwroot \ default website \ sitecore \ data \ mydata.xml".
string filename = FileUtil.MapPath("/sitecore/data/mydata.xml");