2014-10-22 59 views
0

我嘗試獲取項目的當前目錄路徑。 我嘗試:C# - 獲取項目的路徑,n bin路徑

  1. System.IO.Directory.GetDirectoryRoot();

  2. Environment.CurrentDirectory;

  3. System.IO.Path.GetFullPath( 「\」);

,並在所有的選項,我得到:

C:\ Program Files文件(x86)的\ IIS快遞\

而是項目路徑。

有沒有人有解決方案?

+0

您的意思是項目路徑,就像Visual Studio中的.csproj項目文件所在的路徑一樣? – pyrocumulus 2014-10-22 08:06:10

+1

'this.GetType()。Assembly.Location'。 – CodeCaster 2014-10-22 08:09:54

+0

是的,'正在執行程序集!!='項目文件'。你要哪個? – 2014-10-22 08:10:39

回答

0

你可能想嘗試了這一點:

串thePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;

不知道它是否適用於您,但您可以隨時嘗試。