What is the best way to determine application root directory?

前端 未结 5 1718
小蘑菇
小蘑菇 2020-11-30 22:22

I need to get all dlls in my application root directory. What is the best way to do that?

string root = Application.StartupPath;

Or,

<
5条回答
  •  醉酒成梦
    2020-11-30 22:49

    AppDomain.CurrentDomain.BaseDirectory is my go to way of doing so.

    However:

    Application.StartupPath gets the directory of your executable

    AppDomain.BaseDirectory gets the directory used to resolve assemblies

    Since they can be different, perhaps you want to use Application.StartupPath, unless you care about assembly resolution.

提交回复
热议问题