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