ASP .NET当前物理位置 [英] ASP .net current physical location

查看:105
本文介绍了ASP .NET当前物理位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个ASP.net Web应用程序。
我需要找到该网站的当前位置(物理)(或包含组件的bin目录下)。

Hi I am developing an ASP.net web application. I need to find the current location (physical) of the web site (or the bin directory containing the assemblies).

我一直在使用Directory.GetCurrentDirectory()尝试和返回我的ASP .NET临时目录。

I have tried using Directory.GetCurrentDirectory() and that returns me the ASP .net temporary directory.

我真的不喜欢这个主意,包括一个应用程序在我的配置文件设置的绝对路径(EWW!)

I really don't like the idea of include an application setting for the absolute path in my config file (eww!)

任何帮助将是非常美联社preciated! :)

Any help would be much appreciated! :)

结论:

我应该给一些背景,为什么我想的物理文件路径。
谢谢你们您的问题作出迅速反应:)

I should have given some context as to Why I would like the physical file path. Thanks guys for your prompt responses to the question :)

我使用XSL-FO的.NET( FO.net 库)生成PDF。在FO中嵌入图像需要一个绝对路径给出:

I am using XSL-FO for .net (the FO.net library) to generate a PDF. Embedding images in FO requires an absolute path to be given:

<fo:external-graphic src="C:\MyWebsite\images\image1.jpg" />

我需要做的是将当前目录的网站(或bin目录下),这将允许XSL FO渲染器知道在哪里可以找到图像。

What I needed to do was set the current directory to the web site (or bin directory), which would allow the XSL FO renderer to know where to find the image.

推荐答案

您需要 System.Web.HttpRuntime.BinDirectory (到的物理路径斌文件夹), System.Web.HttpRuntime.AppDomainAppPath (物理路径的顶层ASP.NET应用程序文件夹)。

You need System.Web.HttpRuntime.BinDirectory (physical path to the bin folder) and System.Web.HttpRuntime.AppDomainAppPath (physical path to the top-level ASP.NET application folder).

这篇关于ASP .NET当前物理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆