C#-获取项目的路径,n无bin路径

C#-获取项目的路径,n无bin路径,c#,C#,我尝试获取项目的当前目录路径。 我试过: System.IO.Directory.GetDirectoryRoot() Environment.CurrentDirectory System.IO.Path.GetFullPath(“.\”) 在所有选项中,我得到: C:\ProgramFiles(x86)\IIS Express\ 而不是项目路径 有人有解决方案吗?您可能想尝试一下: string thePath=System.Web.Hosting.HostingEnvironm

我尝试获取项目的当前目录路径。 我试过:

  • System.IO.Directory.GetDirectoryRoot()

  • Environment.CurrentDirectory

  • System.IO.Path.GetFullPath(“.\”)

  • 在所有选项中,我得到:

    C:\ProgramFiles(x86)\IIS Express\

    而不是项目路径


    有人有解决方案吗?

    您可能想尝试一下:

    string thePath=System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath


    不确定它是否适合您,但您可以随时尝试。

    您可能想尝试一下:

    string thePath=System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath


    不确定它是否适合您,但您可以随时尝试。

    您可能想尝试一下:

    string thePath=System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath


    不确定它是否适合您,但您可以随时尝试。

    您可能想尝试一下:

    string thePath=System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath


    不确定它是否适合您,但您可以随时尝试。

    我在网上找到一个链接:

    您应该使用:
    string path=AppDomain.CurrentDomain.BaseDirectory


    实际上,其他值在程序执行过程中可能会发生变化。

    我在网上找到了一个链接:

    您应该使用:
    string path=AppDomain.CurrentDomain.BaseDirectory


    实际上,其他值在程序执行过程中可能会发生变化。

    我在网上找到了一个链接:

    您应该使用:
    string path=AppDomain.CurrentDomain.BaseDirectory


    实际上,其他值在程序执行过程中可能会发生变化。

    我在网上找到了一个链接:

    您应该使用:
    string path=AppDomain.CurrentDomain.BaseDirectory


    实际上,其他值在程序执行过程中可能会更改。

    您是指项目路径,就像Visual Studio中的.csproj项目文件所在的路径一样?
    this.GetType().Assembly.Location
    。是的,
    执行程序集
    !=<代码>项目文件
    。您想要哪个?您是指项目路径,如Visual Studio中的.csproj项目文件所在的路径吗?
    this.GetType().Assembly.Location
    。是的,
    正在执行程序集
    !=<代码>项目文件
    。您想要哪个?您是指项目路径,如Visual Studio中的.csproj项目文件所在的路径吗?
    this.GetType().Assembly.Location
    。是的,
    正在执行程序集
    !=<代码>项目文件
    。您想要哪个?您是指项目路径,如Visual Studio中的.csproj项目文件所在的路径吗?
    this.GetType().Assembly.Location
    。是的,
    正在执行程序集
    !=<代码>项目文件
    。你想要哪一个?这是工作!谢谢这是工作!谢谢这是工作!谢谢这是工作!谢谢