Untitled
unknown
plain_text
a month ago
1.6 kB
3
Indexable
Never
using System.IO; using System.Collections.Generic; public class IniFileReader { private Dictionary<string, string> iniData; public IniFileReader(string filePath) { iniData = new Dictionary<string, string>(); LoadIniFile(filePath); } private void LoadIniFile(string filePath) { if (File.Exists(filePath)) { string[] lines = File.ReadAllLines(filePath); foreach (string line in lines) { // Assuming INI file format is key=value string[] parts = line.Split('='); if (parts.Length == 2) { string key = parts[0].Trim(); string value = parts[1].Trim(); iniData[key] = value; } } } } public string GetValueForKey(string key) { if (iniData.ContainsKey(key)) { return iniData[key]; } else { // Return a default value or handle accordingly return string.Empty; } } } public class YourViewModel { private IniFileReader iniReader; public YourViewModel() { // Replace "yourIniFilePath.ini" with the actual path to your INI file iniReader = new IniFileReader("yourIniFilePath.ini"); // Replace "YourKey" with the key you want to retrieve YourTextBoxProperty = iniReader.GetValueForKey("YourKey"); } public string YourTextBoxProperty { get; set; } }