What is the best way to determine application root directory?

前端 未结 5 1709
小蘑菇
小蘑菇 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:53

    I use

    Path.GetDirectoryName(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath)

    The Assembly.Location will point to the shadow copy if you use shadow copying, so using CodeBase is a better option, but CodeBase is a Url.

提交回复
热议问题