前提:winform应用程序开发
请看如下数据库连接字符串: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);
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:百度知道有个类似的东西,可以注意一下。
本文转自 huohe2009 51CTO博客,原文链接:http://blog.51cto.com/zhaojie/932235