What's the best way to get the directory from which an assembly is executing

前端 未结 7 1401
说谎
说谎 2020-12-08 21:40

For my apps, I store some configuration file in xml along with the assembly(exe), and something other temporary files for proccessing purpose.

I found some quirk w

7条回答
  •  隐瞒了意图╮
    2020-12-08 22:13

    Do you want the actual working directory, or the directory containing the assembly? It's not entirely clear.

    There's Environment.CurrentDirectory if you want the working directory, or Path.GetDirectoryName(typeof(Foo).Assembly.ManifestModule.FullyQualifiedName) to find the location of an assembly (or at least its manifest module, which will be the same thing in almost all cases).

提交回复
热议问题