473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to get the "Windows" directory?

Hi,

I'm wondering how you can use the standard C# library to get the
"windows" directory? (e.g. "c:/windows"). I need to specify the
location of a config file in a service, and I don't want to hard-code
anything.

Thanks.

Dec 14 '05 #1
4 14669
"System.Environment.SystemDirectory" returns the fully qualified path
of the system directory (In my case C:\Winnt\system32).

Hope it can help you

Dec 14 '05 #2

"parsifal" <se*************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,

I'm wondering how you can use the standard C# library to get the
"windows" directory? (e.g. "c:/windows"). I need to specify the
location of a config file in a service, and I don't want to hard-code
anything.

Thanks.


Environment.GetEnvironmentVariable("windir");

Note that a config file should not reside in the windows directory either,
it should reside in the same directory as your service .exe.

Willy.
Dec 14 '05 #3
Thanks! That should work well!

Thanks for the lightning-quick reply!

Dec 14 '05 #4
Oh okay, so I can just do relative paths? Sounds fine to me.

Where should services be stored?

Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alchamist | last post by:
Hi all, I am writing a simple app to provide an simple GUI to write windows netlogon scripts. Is there a way in vb.net to provide a button on a form to open the "Active Directory Users and...
7
by: Paul Rubin | last post by:
I'm writing a Windows program that needs to store some user files. The logical place to store them is in "Application Data", right? Is there a good way to find the correct location of that...
11
by: Codemonkey | last post by:
Hi, I am writing an App in .Net that involves some scheduling of tasks. I was wondering if anybody has come accross any components or examples of how to implement a schedule manager like the one...
2
by: unknown | last post by:
I compiled as following (e.g) cl first.cpp but following message ↓ Cannot open include file "windows.h" :Such a file or directory What compile option is used in dotnetframework SDK 1.1 or...
2
by: Twitch | last post by:
Is there an event or "something" that happens where I can Log a message (or whatever) when a logon attempt fails when using "Windows Authentication". If not, I could just do my own logon screen,...
2
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have been struggeling with this Windows, Authentication method for a while, and i am beginning to give up. So a couple of questions that you guys probably have the answer on. 1. One...
1
by: reeferz | last post by:
hi all, i created the most basic webservice the one that vs 2005 creates for u with the hello world method, and decided to post it onto my website.... however i keep getting this error : ...
2
by: ezageza | last post by:
Hi, does anyone know whats going on or how to fix my problem with windows media player 10. When i'm finished using it and am shutting it down it brings up a message saying something like 'windows...
1
by: inungh | last post by:
I tried to place a grid view on my design view and connect to new data source to local SQL Express server Northwind database. I got error message on line 80 <authentication mode="Windows"/> ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.