I have two asp.net projects in one solution. One is WebForms and the another is a WebApi project.
I am trying to save an image in the root folder of the WebForms using a method in the WebApi. Unfortunately, I am unable to get the BaseDirectory
of the WebForms from the WebApi method.
This is what I have tried:
//this returns me only the root folder of the API i.e; D:\Projects\MyApp\API\)
string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
Is it possible to do what I am trying?
I guess you can navigate to you related app if it destination meet some folder tree position requirement using this:
string relativePath = "..\\Web\\";
string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
string webPath = Path.GetFullPath(baseDirectory + relativePath);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.