출처 : http://stackoverflow.com/questions/52797/how-do-i-get-the-path-of-the-assembly-the-code-is-in#283917




웹사이트를 만들 때, 모듈을 따로 개발하는 때가 있다. 


이 때, 로그라던가, 파일 저장이라던가 등의 이유로 모듈에서 파일에 접근해야할 때가 있는데,


httpcontext.current 는 인자값으로 넘기기 귀찮고, 할 때!





public string GetPath()

{

    string codeBase = Assembly.GetExecutingAssembly().CodeBase;

    UriBuilder uri = new UriBuilder(codeBase);

    string path = Uri.UnescapeDataString(uri.Path);

    return Path.GetDirectoryName(path);

}



해당 모듈(DLL)에서 DLL의 위치를 알고 싶을 때 사용 하는 함수이다.

























Posted by motolies
,