Click here to Skip to main content
11,641,708 members (48,716 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Delphi
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.
Posted 11-Nov-10 9:57am
Edited 11-Nov-10 10:06am
Sauro Viti15.7K
v2
Comments
Toli Cuturicu at 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
good
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[^]
  Permalink  
Rate this: bad
good
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#"[^].
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

http://www.codeproject.com/info/search.aspx[^]
Then type ini in the search box and press enter!
Voila, lots of IniFile implementations!
  Permalink  

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

  Print Answers RSS
0 Mika Wendelius 260
1 DamithSL 248
2 Afzaal Ahmad Zeeshan 129
3 OriginalGriff 120
4 Sergey Alexandrovich Kryukov 80
0 Mika Wendelius 460
1 OriginalGriff 265
2 DamithSL 258
3 CPallini 169
4 Afzaal Ahmad Zeeshan 149


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 12 Nov 2010
Copyright © CodeProject, 1999-2015
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