資源簡介
C# WinForm讀寫INI文件
C# WinForm讀寫INI文件
C# WinForm讀寫INI文件
C# WinForm讀寫INI文件
C# WinForm讀寫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.IO;
namespace?IniDemo
{
????public?partial?class?Form1?:?Form
????{
????????public?string?IP?Port?AppName?Password?DBConnectString?gameWinRateUpDown?killRateUpDown;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?btnOK_Click(object?sender?EventArgs?e)
????????{
????????????IP?=?txtIP.Text;
????????????Port?=?txtPort.Text;
????????????AppName?=?txtAppName.Text;
????????????Password?=?txtPassword.Text;
????????????DBConnectString?=?txtDBConnet.Text;
????????????gameWinRateUpDown?=?GameWinRateUpDown.Text;
????????????killRateUpDown?=?KillRateUpDown.Text;
????????????StreamWriter?sw?=?new?StreamWriter(“game.ini“?false?Encoding.GetEncoding(“gb2312“));
????????????sw.Flush();
????????????sw.WriteLine(IP);
????????????sw.WriteLine(Port);
????????????sw.WriteLine(AppName);
????????????sw.WriteLine(Password);
????????????sw.WriteLine(DBConnectString);
????????????sw.WriteLine(gameWinRateUpDown);
????????????sw.WriteLine(killRateUpDown);
????????????sw.Close();
????????????this.Close();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????StreamReader?sr?=?new?StreamReader(“game.ini“?Encoding.GetEncoding(“gb2312“));
????????????if?(sr.Peek()?>=?0)
????????????{
????????????????txtIP.Text?=?sr.ReadLine();
????????????????txtPort.Text?=?sr.ReadLine();
????????????????txtAppName.Text?=?sr.ReadLine();
????????????????txtPassword.Text?=?sr.ReadLine();
????????????????txtDBConnet.Text?=?sr.ReadLine();
????????????????GameWinRateUpDown.Text?=?sr.ReadLine();
????????????????KillRateUpDown.Text?=?sr.ReadLine();
????????????}
????????????sr.Close();
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????81??2009-03-30?23:50??IniDemo\bin\Debug\game.ini
?????文件??????12288??2009-03-30?23:48??IniDemo\bin\Debug\IniDemo.exe
?????文件??????22016??2009-03-30?23:48??IniDemo\bin\Debug\IniDemo.pdb
?????文件??????14328??2009-03-30?23:51??IniDemo\bin\Debug\IniDemo.vshost.exe
?????文件????????490??2007-07-21?01:33??IniDemo\bin\Debug\IniDemo.vshost.exe.manifest
?????文件???????1940??2009-03-30?23:48??IniDemo\Form1.cs
?????文件??????13040??2009-03-30?23:48??IniDemo\Form1.Designer.cs
?????文件???????5814??2009-03-30?23:48??IniDemo\Form1.resx
?????文件???????3725??2009-03-30?23:48??IniDemo\IniDemo.csproj
?????文件????????556??2009-03-30?23:51??IniDemo\obj\Debug\IniDemo.csproj.FileListAbsolute.txt
?????文件????????847??2009-03-30?23:48??IniDemo\obj\Debug\IniDemo.csproj.GenerateResource.Cache
?????文件??????12288??2009-03-30?23:48??IniDemo\obj\Debug\IniDemo.exe
?????文件????????180??2009-03-30?23:48??IniDemo\obj\Debug\IniDemo.Form1.resources
?????文件??????22016??2009-03-30?23:48??IniDemo\obj\Debug\IniDemo.pdb
?????文件????????180??2009-03-30?23:48??IniDemo\obj\Debug\IniDemo.Properties.Resources.resources
?????文件????????488??2009-03-30?23:40??IniDemo\Program.cs
?????文件???????1346??2009-03-30?23:40??IniDemo\Properties\AssemblyInfo.cs
?????文件???????2864??2009-03-30?23:40??IniDemo\Properties\Resources.Designer.cs
?????文件???????5612??2009-03-30?23:40??IniDemo\Properties\Resources.resx
?????文件???????1092??2009-03-30?23:40??IniDemo\Properties\Settings.Designer.cs
?????文件????????249??2009-03-30?23:40??IniDemo\Properties\Settings.settings
?????目錄??????????0??2009-03-30?23:40??IniDemo\obj\Debug\TempPE
?????目錄??????????0??2009-03-30?23:49??IniDemo\bin\Debug
?????目錄??????????0??2009-03-30?23:48??IniDemo\obj\Debug
?????目錄??????????0??2009-03-30?23:40??IniDemo\bin
?????目錄??????????0??2009-03-30?23:40??IniDemo\obj
?????目錄??????????0??2009-03-30?23:40??IniDemo\Properties
?????目錄??????????0??2009-03-30?23:48??IniDemo
-----------?---------??----------?-----??----
???????????????121440????????????????????28
............此處省略1個文件信息
評論
共有 條評論