config檔案的兩種讀取方式

2022-03-07 03:39:53 字數 613 閱讀 6559

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 getaccounts(stringpath)

2 ;19

20 if (bool.parse(account.isadmin))

21 24

25 accounts.add(account);

26 }

27 }

其中path可以使用相對路徑:

string path = @"

../debug/accounts.config

";

也可以使用絕對路徑,根據專案需要新增,另外多說一句,如果想使用計畫任務執行程式,必須使用絕對路徑

Perl讀取檔案的兩種常用方式

整體讀入,逐行處理 open file,home chenmi bashrc die cannot open the file n linelist foreach eachline linelist close file 逐行讀入,邊讀邊處理 open file,home chenmi bashr...

vue讀取本機的excel檔案的兩種方式

安裝依賴 npm install xlsx 引入import xlsx from xlsx 第一種input通常方式 template中加入input data中宣告變數 data mounted中繫結事件 mounted 呼叫主函式 readexcel e else if xls xlsx tes...

讀取不同格式檔案的兩種方式

方式一 含有多行,每行含有一列資料 int filereader char file,double a for int i 0 fscanf fp1,lf a i eof i 從輸入檔案連續讀取浮點型數到陣列a fclose fp1 關閉輸入檔案 return 1 方式二 含有多行,每行含有多列資料...