I’ve been using the same method called CheckIfImageExiste(string virtualPath, string finename) on 3 pages now because the method contains the method Server.MapPath.
The method is supposed to receive a virtual path and image file’s name and check if the the image is in the right folder. So when the method receive the parameter, it needs to translate it into a physical path.
in a code behind, I can do something like:
string physicalPath = Server.MapPath(virtualPath);
But, if I decide to move CheckIfImageExiste() to another class so that it can be shared by all 3 classes, how can I define Server.MapPath(virtualPath) in the new class? I mean, what are the references?
Thanks for helping
HttpServerUtility should be available:
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.aspx
…or you could pass your new function a reference to the page itself.