我看到有一些方法可以获取应用程序文件夹路径:
Application.StartupPathSystem.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location)AppDomain.CurrentDomain.BaseDirectorySystem.IO.Directory.GetCurrentDirectory()Environment.CurrentDirectorySystem.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)System.IO.Path.GetDirectory(Application.ExecutablePath)取决于具体情况,最好的方法是什么?
任何人能解释的区别Server.MapPath("."),Server.MapPath("~"),Server.MapPath(@"\")和Server.MapPath("/")?
我无法使用Application_Start中的当前物理路径
HttpContext.Current.Request.PhysicalApplicationPath
Run Code Online (Sandbox Code Playgroud)
因为那时没有Request对象.
我怎样才能获得物理路径?
我在wwwroot / img文件夹中有一个图像,想在服务器端代码中使用它。
如何在代码中获取此图像的路径?
代码是这样的:
Graphics graphics = Graphics.FromImage(path)
Run Code Online (Sandbox Code Playgroud) 当我使用visual studio运行我的网站时,它的根URL是: http://localhost:4657
我有包含路径的字符串~/Login.aspx,我需要连接它们以便返回http://localhost:4657/Login.aspx.
我可以看到很多方法来做到这一点,但正确的方法是什么?