【问题标题】:How to determine the path that was used to start the current application? [duplicate]如何确定用于启动当前应用程序的路径? [复制]
【发布时间】:2014-01-06 21:39:09
【问题描述】:

我们如何确定正在运行的应用程序的文件系统位置?

【问题讨论】:

  • 这取决于应用程序的类型:控制台、winforms、wpf、asp.net、windows phone ......我希望你意识到你用 C# 标记你的问题是毫无意义的在这种情况下。
  • application.info.path 和许多其他属性将为您提供帮助
  • ... 或 thisthisthisthisthis ... 如果网站建议检查您的问题是否曾被问过,请这样做

标签: c#


【解决方案1】:

如果您在控制台上工作,请使用此

AppDomain.CurrentDomain.BaseDirectory

或在 Windows 窗体上使用

Application.StartupPath 

【讨论】:

  • @TravisBanger:你的问题没有给出任何迹象。您应该添加适当的标签。专业提示:添加 WPF 参考后,您的问题与 this questionthat one 重复。
【解决方案2】:

Environment.GetCommandLineArgs()[0];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多