![](/img/trans.png)
[英]Copy one file from a project's output directory to another project's output directory
[英]Get Base Directory of one project from another project's class
我在一个解决方案中有两个asp.net项目。 一个是WebForms,另一个是WebApi项目。
我正在尝试使用WebApi中的方法将图像保存在WebForms的根文件夹中。 不幸的是,我无法获得BaseDirectory
从的WebAPI方法的WebForms的。
这是我尝试过的:
//this returns me only the root folder of the API i.e; D:\Projects\MyApp\API\)
string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
可以做我想做的事吗?
我想如果目标满足某些文件夹树位置要求,您可以使用以下方法导航到您相关的应用程序:
string relativePath = "..\\Web\\";
string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
string webPath = Path.GetFullPath(baseDirectory + relativePath);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.