config 檔案讀取

2022-03-21 17:56:47 字數 747 閱讀 7574

在專案中我們經常要使用到config檔案進行相應的配置,來使我們的專案更加靈活健壯。 

1、首先 我們在要使用config的專案中引入system.configuration類庫,

2、然後

值得一體的是:

一開始我想著我是在dal層中讀取資料庫配置,所以就想著在dal層自己新增config檔案,新增system.configuration引用,然後讀取對應的配置,

原因是因為 dal層讀取的配置檔案是最終引用dal層的ui層中的web.config 檔案,所以只需要在ui層的web.config 檔案中新增對應配置就可以!

其實我想如果非要在dal層使用自己新增的config檔案,只需要在dal層讀取自己新增的config檔案 然後讀取配置就可以了 ,但是我覺得最簡單便捷的方式就是直接讀取ui層的webconfig 就妥妥的啦

讀取配置config檔案

123 from fish.q.li newegg.com 45 67讀取上面 的xml 14 15 1617 18 configurationcollection typeof mykeyvaluesetting 19public class mykeyvaluecollection config...

linux下config配置檔案的讀取

linux讀取config配置檔案 適用於 config email email option from name option enable notification 1 option do not validate 0 option port 25 option from email addre...

config檔案的兩種讀取方式

1.專案預設的讀取webconfig中的,如下 1 public voidgetaccounts 2 3 34 35 accounts.add account 36 37 38 39 40 41 42 43 2.指定位置的讀取方式 自己新增的config檔案 1 public void getacc...