Skip to content

Class IniFile ​

Namespace: Tool.Utils.Other
Assembly: Tool.Net.dll

INI文件读写类。 Copyright (C) Maticsoft

csharp
public class IniFile

Inheritance ​

object ← IniFile

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks ​

代码由逆血提供支持

Constructors ​

IniFile(string) ​

有参构造,ini文件的绝对路径

csharp
public IniFile(string INIPath)

Parameters ​

INIPath string

Fields ​

path ​

INI文件的路径

csharp
public string path

Field Value ​

string

Methods ​

ClearAllSection() ​

删除ini文件下所有段落

csharp
public void ClearAllSection()

ClearSection(string) ​

删除ini文件下personal段落下的所有键

csharp
public void ClearSection(string Section)

Parameters ​

Section string

IniReadValue(string, string) ​

读取INI文件

csharp
public string IniReadValue(string Section, string Key)

Parameters ​

Section string

欲在其中查找条目的小节名称。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载这个ini文件所有小节的列表。

Key string

欲获取的项名或条目名。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载指定小节所有项的列表

Returns ​

string

IniReadValues(string, string) ​

读取INI文件

csharp
public byte[] IniReadValues(string Section, string Key)

Parameters ​

Section string

欲在其中查找条目的小节名称。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载这个ini文件所有小节的列表。

Key string

欲获取的项名或条目名。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载指定小节所有项的列表

Returns ​

byte[]

IniWriteValue(string, string, string) ​

写INI文件

csharp
public void IniWriteValue(string Section, string Key, string Value)

Parameters ​

Section string

要在其中写入新字串的小节名称。这个字串不区分大小写

Key string

要设置的项名或条目名。这个字串不区分大小写。用vbNullString可删除这个小节的所有设置项

Value string

指定为这个项写入的字串值。用vbNullString表示删除这个项现有的字串

基于Apache-2.0协议开源