欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

C#中實(shí)現(xiàn)INI配置文件的方法

這篇文章主要介紹了C#中實(shí)現(xiàn)INI配置文件的方法,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的天津網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

創(chuàng)建如圖所示的控件:

C#中實(shí)現(xiàn)INI配置文件的方法

源代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication3

{

  public partial class Form1 : Form

  {

    public Form1()

    {

      InitializeComponent();

    }

 

    [DllImport("kernel32.dll")]

    private static extern long WritePrivateProfileString(string section, string key, string value, string filepath);

 

    [DllImport("kernel32.dll")]

    private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder returnvalue,intbuffersize,string filepath);

 

    private string IniFilePath;
    private void Form1_Load(object sender, EventArgs e)

    {

      comboBox1.Text = "男";

      for (int i = 1; i <= 100; i++)

      {

        comboBox2.Items.Add(i.ToString());

      }

      comboBox2.Text = "18";

      IniFilePath = Application.StartupPath + "\\Config.ini";

    }

 

    private void button1_Click(object sender, EventArgs e)
    {
      if ((textBox1.Text.Trim() != "") && (textBox2.Text.Trim() != ""))
      {
        string Section = "Information";
        try

        {

          WritePrivateProfileString(Section, "Name", textBox1.Text.Trim(), IniFilePath);
          WritePrivateProfileString(Section, "Gender", comboBox1.Text, IniFilePath);
          WritePrivateProfileString(Section, "Age", comboBox2.Text, IniFilePath);
          WritePrivateProfileString(Section, "Region", textBox2.Text.Trim(), IniFilePath);

        }
        catch (Exception ee)

        {

          MessageBox.Show(ee.Message);

        }
      }

      else

      {

        MessageBox.Show("姓名或地區(qū)不能為空!", "錯(cuò)誤", MessageBoxButtons.OK, MessageBoxIcon.Warning);

      }
    }

 

    private void button2_Click(object sender, EventArgs e)
    {
      string outString;
      try

      {
        GetValue("Information", "Name", out outString);
        textBox1.Text = outString;
        GetValue("Information", "Gender", out outString);
        comboBox1.Text = outString;
        GetValue("Information", "Age", out outString);
        comboBox2.Text = outString;
        GetValue("Information", "Region", out outString);
        textBox2.Text = outString;

      }

      catch (Exception ee)

      {

        MessageBox.Show(ee.Message);

      }

 

    }

 

    private void GetValue(string section,string key, out string value)
    {

      StringBuilder stringBuilder = new StringBuilder();
      GetPrivateProfileString(section, key, "", stringBuilder, 1024, IniFilePath);
      value = stringBuilder.ToString();

    }

 

    private void button3_Click(object sender, EventArgs e)

    {
      textBox1.Text = "";
      comboBox1.Text = "男";
      comboBox2.Text = "18";
      textBox2.Text = "";
    }

  }

}

運(yùn)行結(jié)果:

C#中實(shí)現(xiàn)INI配置文件的方法

C#中實(shí)現(xiàn)INI配置文件的方法C#中實(shí)現(xiàn)INI配置文件的方法C#中實(shí)現(xiàn)INI配置文件的方法C#中實(shí)現(xiàn)INI配置文件的方法

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“C#中實(shí)現(xiàn)INI配置文件的方法”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!

網(wǎng)頁名稱:C#中實(shí)現(xiàn)INI配置文件的方法
地址分享:http://aaarwkj.com/article20/jjgojo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)品牌網(wǎng)站制作、軟件開發(fā)用戶體驗(yàn)、標(biāo)簽優(yōu)化Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)
一区二区三区免费在线观看视频| 国产一区二区精品日韩| 亚洲精品国产熟女高潮| 一本久久精品午夜福利| 成人性生活黄色三级视频| 蜜臀av网站在线播放| 亚洲午夜福利啪啪啪| 国产91人妻精品一区二区三区| 亚洲欧美日韩一区中文天国| 亚洲成人免费在线一区| 精品人妻少妇av一区二区| 日本一区二区三区高清| 美腿丝袜清纯唯美亚洲另类| 中文一级伦理一区二区| 91在线免费观看国产精品| 欧美日韩国产亚洲免费| 少妇精品偷拍高潮少妇在线观看 | 91中文字幕在线一区| 视频一区日本视频二区| 国产精品精品国产一区二区| 精品亚洲一区二区三区四| 毛片91成人在线播放| 四影虎影永久免费观看| 91在线视频国产网站| 日本一区二区在线观看视频| 国产精品美女自拍视频| av国语对白在线观看| 日韩高清av一区二区三区| 成人黄色小视频下载| 欧美日韩亚洲视频一区久久| 欧美日韩国产av一区| 精品欧美黑人一区二区| av国产一区二区在线| 午夜少妇福利在线观看| 把熟睡的少妇弄到高潮| 久久久人妻精品一区二区三区四区| 久久精品国产精品日韩欧美| 91高清国产在线播放| 精品人妻在线中文字幕| 亚洲成在人天堂一区二区| 亚洲日本在线观看午夜视频|