簡體   English   中英

從另一個項目的類獲取一個項目的基本目錄

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM