請看如下資料庫連接配接字元串:string strcn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database\LandInspect.mdb;Persist Security Info=False;";
其他略去不表,Data Source=|DataDirectory|是代表哪個路徑呢?
By default this variable will be expanded as:
•For a local Application this will be the Assembly (App's .exe) folder;
•For ClickOnes running Apps it will be a special data folder created by ClickOnes;
•For ASP.NET App it will be App_Data folder.
Because the |DataDirectory| is a property of App domain, you can change its value by doiung
AppDomain.CurrentDomain.SetData("DataDirectory", newDataPath);
說白了,在winform中,除非你另外設定,否則就是Debug檔案夾。
PS:百度知道有個類似的東西,可以注意一下。
<a href="http://blog.51cto.com/attachment/201207/101029612.png" target="_blank"></a>
本文轉自 huohe2009 51CTO部落格,原文連結:http://blog.51cto.com/zhaojie/932235