Click here to Skip to main content
15,799,398 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Can any one help me to convert this delphi code to C#.

class function TShrinkConfig.MyVersion: WORD;
ini: TIniFile;
ini := TIniFile.Create(gsIniFile);
Result := ini.ReadInteger(


if (not ini.ValueExists(SHRINK_INI_VERSIONS_SECTION, IntToStr(version))) then

I searched online that TiniFile corresponds to FileStream in C#.
But i am not able to understand and convert it into C#.

Help would be really appreciated.
Updated 11-Nov-10 11:06am
Toli Cuturicu 11-Nov-10 20:19pm    
OP's fake answer:
Ok kool .. This should work.
But i have seen that it has methods for reading and writing into INI.
But if i want to do something like check if value exists.
Is there any way for that.

Thanks for the replies.

I think that TIniFile doesn't corresponds to FileStream: probably it is related to the old .ini files which are deprecated and not directly supported in the .NET Framework.
However you can access them using the P/Invoke; the Win32 API that you need is GetPrivateProfileInt[^]
Share this answer
You probably need a C# wrapper class around Win32 INI file API. Have a look at this CodeProject's article: "An INI file handling class using C#"[^].
Share this answer
Then type ini in the search box and press enter!
Voila, lots of IniFile implementations!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900