Is there a WriteProfileString support directly in C#? I do not want to use the unmanaged function from kernel32.dll.
A:
No, as far as I know, .NET does not support INI files anymore.
In the .NET world, the INI file format has been widely replaced by XML, which is the new de-facto standard for configuration files (e.g. app.config
files for which the .NET Framework provides support through the static System.Configuration.ConfigurationManager
class).
stakx
2010-07-01 21:43:06
WriteProfileString generally goes to the registry, not a INI file.
Mark Ransom
2010-07-01 21:48:04
@Mark Ransom: http://msdn.microsoft.com/en-us/library/ms725504%28VS.85%29.aspx. Despite that, I must concede that you're probably correct. However, my answer focuses on the topic of INI vs. XML because the question is tagged with `file-io` and `ini`. Furthermore, if this is about the registry instead of about INI files, I would see absolutely *no* reason for not using P/Invoke to the named API functions; probably the strongest argument against P/Invoke, namely platform independence, wouldn't be relevant in the first place.
stakx
2010-07-01 21:51:23
Thanks guys. I have decided to just go the XML route to avoid calling using interop calls in managed code.
Subbu
2010-07-23 16:24:18