Click here to Skip to main content
16,015,583 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;
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
Updated 11-Nov-10 10:06am
v2
Comments
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
 
v2
http://www.codeproject.com/info/search.aspx[^]
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