일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 26 |
27 | 28 | 29 | 30 |
- java
- Unity
- flutter
- aduino
- Class
- c++
- APP
- wpf
- length
- preprocessing
- Read
- memory
- public
- Android
- Contour
- Encapusulation
- digitalRead
- inheritance
- stream
- sensor
- atmega328
- file access
- SERIAL
- UNO
- Overloading
- parameter
- compare
- Barcode
- mfc
- Pointer
- Today
- Total
폴크(FOLC)
C# 테크닉 - 파일 제어( INI format ) 본문
# WPF 를 이용하는 과정에서 HDD 에 존재하는 파일 ( ini format ) 제어
> Save, Load 형태 - DllImport("kernel32") 이용
> exe 파일 위치에 test.ini 파일 생성
# 소스 코드
using System.Runtime.InteropServices;
public class INIformat
{
DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filepath);
public void WriteReadTest()
{
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
path = System.IO.Path.GetDirectoryName(path) + "\\test.ini";
WritePrivateProfileString("SECTION", "KEY1", "VALUE1", path);
StringBuilder retVal = new StringBuilder();
GetPrivateProfileString("SECTION", "KEY1", "def", retVal, 32, path);
}
'C#, WF, WPF(.NET) > C#, WF, WPF(.NET) 테크닉' 카테고리의 다른 글
C# 테크닉 - 통신 Socket ( Client ) (0) | 2021.12.01 |
---|---|
C# 테크닉 - 파일 제어( BIN format ) (0) | 2021.11.30 |
C# 테크닉 - Page 전환 (0) | 2021.11.12 |
WPF 테크닉 - Page 전환 (0) | 2021.11.12 |
C# 테크닉 - 이미지 캡처 ( 크롤링 ) (0) | 2021.11.09 |