Click here to Skip to main content
13,193,048 members (80,267 online)
Rate this:
Please Sign up or sign in to 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.
Posted 11-Nov-10 9:57am
Updated 11-Nov-10 10:06am
Sauro Viti15.8K
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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#"[^].
Rate this: bad
Please Sign up or sign in to vote.

Solution 3[^]
Then type ini in the search box and press enter!
Voila, lots of IniFile implementations!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171017.2 | Last Updated 12 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100