C#
02#INI 파일 읽기 쓰기
NaHyungMin
2016. 4. 18. 17:36
C#에서 INI에 읽기 쓰기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | using System.Runtime.InteropServices; using Microsoft.Win32; //ini 파일 API 함수 [DllImport("kernel32.dll")] //Read private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); [DllImport("kernel32.dll")] //Write private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); //파일 쓰기 private void wirteValue(string section, string key, string value, string filePath) { WritePrivateProfileString(section, key, value, filePath); } //파일 읽기 private void readValue(string section, string key, string filePath) { StringBuilder sb = new StringBuilder(); GetPrivateProfileString(section, key, "", sb, 2000, filePath); return sb.ToString(); } | cs |