How can I get special system directory?

How can I get special system directory?

I want to know special system directory? such as c:\Windows c:\windows\system32 ...
what do I do?

I see the following code from a sample

openFileDialog1.InitialDirectory="%SystemRoot%"; // it work well
openFileDialog1.ShowDialog();

I think the code should be the below:

openFileDialog1.InitialDirectory=Environment.ExpandEnvironmentVariables("%SystemRoot%");
openFileDialog1.ShowDialog();

Why does openFileDialog1.InitialDirectory="%SystemRoot%" work well?

but the following ...
string path=Environment.ExpandEnvironmentVariables("%SystemRoot%\\"+"1.jpg"); //OK
string path="%SystemRoot%\\"+"1.jpg"; //it doesn't work, why?

[743 byte] By [CUIWEI] at [2007-12-16]
# 1

Hi,

Here's a way to get the environment directories.

Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

Just check the values in SpecialFolder Enum...

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Environment.SpecialFolder exclude C:\windows folder
CUIWEI at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3

Hi,

Your right. I wonder why they didn't include it. But you can get a system variable that holds this value:

Environment.GetEnvironmentVariable("windir")

This will return the installed windows dir...

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...