Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative of System.Web.HttpContext.Current when using ProgressBox

Tags:

sitecore

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?

like image 665
Ahmed Okour Avatar asked May 15 '26 00:05

Ahmed Okour


2 Answers

You can use

HostingEnvironment.MapPath(string path)
like image 115
Marek Musielak Avatar answered May 19 '26 02:05

Marek Musielak


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");
like image 20
Sean Kearney Avatar answered May 19 '26 02:05

Sean Kearney



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!