简体   繁体   English

如何获取物理目录路径到服务器创建的路径?

[英]How to get physical directory path to path created by server?

I have an asp.net mvc web application that I deployed to a server. 我有一个部署到服务器的asp.net mvc Web应用程序。 The app has an exe file that I keep in a known parent directory on my local machine and I call it using MapPath like this: 该应用程序有一个exe文件,我将其保存在本地计算机上的已知父目录中,并使用MapPath调用它,如下所示:

string path = HttpContext.Current.Server.MapPath("~/parentDirectory/");.

The problem is, the server where I deploy to, doesn't keep the file in the same directory and I therefore have no way of calling it during compile time using this method. 问题是,我部署到的服务器没有将文件保存在同一目录中,因此我无法在编译期间使用此方法调用该文件。 Is there any way I can call the exe file dynamically just by its name or another way to get the server's path? 有什么方法可以仅通过文件名来动态调用exe文件,也可以通过其他方法获取服务器的路径?

最好的选择是在web.config文件中使用appsetting,并在部署应用程序时让服务器管理员添加路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM