Wednesday, January 8, 2014

How to read *.ini file in powershell, ps, c#

if you open up ini file from command prompt using type command or get-content from powershell, the output you get will be sparse with spaces. To avoid this you need to open it in the format it was saved as.

 $iniFile = $env:localappdata+"\Microsoft\Windows\SkyDrive\settings\" + $cid + ".ini"
$text = [system.io.File]::ReadAllText($iniFile, [system.text.Encoding]::GetEncoding("Unicode"));

To open up it other formats reference to this MSDN link :-
http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx

Node.JS rest api Tutorials