File Path

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique
 
Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique

You can use Server.MapPath() to get the absolute URL of a file on the
website and pass that to your DLL
 
news.microsoft.com said:
Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique

If your class library has a reference to System.Web, you could use the
following:

using System.Web;
using System.Web.UI;
public class TestWebClass
{
private Page CurrentPage {
get {
return HttpContext.Current.Handler as Page;
}
}

public string GetWebAppRoot() {
if (this.CurrentPage is null) return string.Empty;
return this.CurrentPage.Request.ApplicationPath;
}

public string GetCurrentPagePath() {
if (this.CurrentPage is null) return string.Empty;
return this.CurrentPage.Request.Path;
}
}

This is typed up, so may not compile due to typos...otherwise, should work
fine.

HTH,
Mythran
 
Back
Top