Retrieving the Windows path and reading settings file

G

Guest

I need to read settings for another application for a very small application.
The settings are stored in a text file, and this file is stored in the
Windows directory.

How can I retrieve the path for the Windows Directory on the local machine?
How do I best read the settings in this file? The settings are in the format
[Data]
datapath=x:\xxx
[Reports]
ReportPath=x:\xxx

I can of course read it as any text file and check every line for what I
need, but there must be a better way of doing it. The settings file contains
about 200 settings, but I only need three of them for my application.
 
L

LOZANO-MORÁN, Gabriel

How can I retrieve the path for the Windows Directory on the local
machine?

One way is:
Environment.GetEnvironmentVariable("WINDIR")

How do I best read the settings in this file? The settings are in the format
[Data]
datapath=x:\xxx
[Reports]
ReportPath=x:\xxx

Looks like a plain INI file to me, unfortunately there is no support voor
INI files in the .NET base class library. You can still however use
unmanaged calls to Win32 API functions like GetPrivateProfileString

Gabriel Lozano-Morán
 
G

Guest

Thanks Gabriel,

That was the answer I was looking for.

Regards,

Kenneth


LOZANO-MORÃN said:
How can I retrieve the path for the Windows Directory on the local
machine?

One way is:
Environment.GetEnvironmentVariable("WINDIR")

How do I best read the settings in this file? The settings are in the format
[Data]
datapath=x:\xxx
[Reports]
ReportPath=x:\xxx

Looks like a plain INI file to me, unfortunately there is no support voor
INI files in the .NET base class library. You can still however use
unmanaged calls to Win32 API functions like GetPrivateProfileString

Gabriel Lozano-Morán
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top