asp.net 擷取當前項目路徑

來源:互聯網
上載者:User

標籤:winform   style   blog   color   ar   os   使用   sp   for   

方法一:
//擷取當前項目的路徑

System.AppDomain.CurrentDomain.BaseDirectory.ToString();   // 得到的是當前項目的根目錄
取的值:F://Project//System2.0//SystemForm//

方法二:

//擷取當前項目的路徑 
//Server對象在頁面中使用

string path=Server.MapPath(".");
取的值:F://Project//System2.0//SystemForm//secure

 C# 擷取當前項目路徑     //擷取和設定目前的目錄(即該進程從中啟動的目錄)的完全限定路徑。

        string str = System.Environment.CurrentDirectory;

        //result: X:/xxx/xxx (.exe檔案所在的目錄)

同樣是C# 語言,在不同的項目裡,有不同的結果。在web項目中用,System,Environment.CurrentDirectory得到的是VS的路徑。但是在winform項目裡,得到的是當前項目的debug路徑。

asp.net 擷取當前項目路徑

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.