Click here to Skip to main content
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 10:57am
Edited 11-Nov-10 11: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 OriginalGriff 475
1 Maciej Los 339
2 Richard MacCutchan 225
3 BillWoodruff 219
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 12 Nov 2010
Copyright © CodeProject, 1999-2014
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