usingSystem;usingSystem.IO;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Runtime.InteropServices;usingSystem.Text;namespacefile_io{ Public classInifile { Public stringPath; Public stringSection ; Public stringKey; Public stringvalue; PublicInifilestringpath) { This. Path=path; }#regionAPI functions declaring read-write INI[DllImport ("kernel32")] Private Static extern LongWritePrivateProfileString (stringSectionstringKeystringValstringFilePath); [DllImport ("kernel32")] Private Static extern intGetPrivateProfileString (stringSectionstringKeystringDefval, StringBuilder RetVal,intSizestringFilePath); [DllImport ("kernel32")] Private Static extern intGetPrivateProfileString (stringSectionstringKeystringDefval, byte[] RetVal,intSizestringFilePath);#endregion
C # code is implemented as follows
Public void openorcreat () { if (file.exists (Path)) { } else { File.create (Path); } }
C # code implementation
Public stringInireadvalue (stringSection,stringKey) {StringBuilder temp=NewStringBuilder (255); inti = getprivateprofilestring (section, Key,"", temp,255, This. Path); returntemp. ToString (); } Public stringInireadvalue () {returninireadvalue (section, Key); }
C # code implementation
Public void Iniwritevalue () { iniwritevalue (section, Key, value); } Public void Iniwritevalue (string string string value) { this . Path); }
C # code implementation
Public void RemoveKey (stringstring Key) { null); }
C # code implementation
Public string[] Getkeynames (stringSection ) { byte[] AllKeys = inireadvalues (section,NULL); string[] keylist; stringkeynames; ASCIIEncoding Scii=Newasciiencoding (); Keynames=Scii. GetString (AllKeys); Keylist= Keynames. Split (New Char[1] {' /' }); returnkeylist; }
C # implementation
Public string[] Getsectionnames () {byte[] allsection = Inireadvalues (NULL,NULL); string[] sectionlist; stringsections; ASCIIEncoding ASCII=Newasciiencoding (); Sections=ASCII. GetString (allsection); Sectionlist= sections. Split (New Char[1] {' /' }); returnsectionlist; }
C # code implementation
public void Removesection (string sections) { iniwritevalue (section, NULL, NULL); }
"LabVIEW to C # 1" INI operation