Can any one help me to convert this delphi code to C#.

class function TShrinkConfig.MyVersion: WORD;
var
ini: TIniFile;
begin
ini := TIniFile.Create(gsIniFile);
Result := ini.ReadInteger(
SHRINK_INI_SETUP_SECTION,
SHRINK_INI_MYVERSION,
SHRINK_INI_VERSION_1);

ini.Free;
end;

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.

A TIniFile doesn't directly correspond to FileStream. It's much more specific and is a class for dealing with INI files, files that are text files and which split information between sections - things in a file between square brackets, a way to group similar things together - and key/value pairs. Under each section will be a number of pairs like

[Section1]
Key1=Value1
Key2=Value2

[Section2]
Key3=Value3

...etc

In order to transition that code from Delphi to C# you'd need to either write your own methods for handling INI file data (easy enough to do) or search online as there are hundreds of solutions people have already posted to the same issue.

INI files were for years the de facto place to store application and operating system configuration data as it was easily readable and editable by person and machine. Nowadays developers are more likely to use XML to store such information, but if you poke around in the average Windows directory you'll come across loads of files with an INI extension formatted as above.

Hope this helps.

Thanks for the reply.

My problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.