Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current directory in a web service

I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the current directory in a web service?

Thanks Stuart

like image 324
user23149 Avatar asked Oct 25 '08 09:10

user23149


People also ask

How do I find current directory?

To determine the exact location of your current directory within the file system, go to a shell prompt and type the command pwd. This tells you that you are in the user sam's directory, which is in the /home directory. The command pwd stands for print working directory.

What is current directory path?

The current directory is the current working directory, and is first in the search order when working with REXX File System (RFS). The current directory can be set using the CD command, CD. The CD command has a similar format to the cd command in operating systems such as DOS.

Which function is used to get location of the current directory?

The pwd command displays the full, absolute path of the current, or working, directory.


2 Answers

In a webservice, you are running in a http context. So,

HttpContext.Current.Server.MapPath("~/")  

will give you the answer.

like image 154
driis Avatar answered Oct 09 '22 08:10

driis


You can use

AppDomain.CurrentDomain.BaseDirectory; 

This gives you the root directory of your application.

like image 44
user3866085 Avatar answered Oct 09 '22 07:10

user3866085