473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14698
"System.Environ ment.SystemDire ctory" returns the fully qualified path
of the system directory (In my case C:\Winnt\system 32).

Hope it can help you

Dec 14 '05 #2

"parsifal" <se************ *@gmail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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.Get EnvironmentVari able("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
2695
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 Computers" dialog? Cheers, Jay
7
11822
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 directory, preferably without any C extensions? It's ok if the directory is found at installation time rather than runtime, and bdist_wininst does have a way to find it from a post-installation script. The trouble is that the post-installation...
11
4083
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 in the Task Scheduler for Windows? Basically I'm after something that'll allow me to specify a "recurring" or "once off" schedule with advanced options like "the first monday in the month" etc.
2
7575
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 in visual C++ toolkit2003?
2
1566
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, but then how could I take the credentials supplied and verify them against the Windows User list at the server? Thanks.
2
1273
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 should add the user to the Active Directory, right? 2. Could i use the Login components to validate the user? (Studio 2005) 3. Do i have to specify every user in the Web.Config?
1
28065
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 : <authentication mode="Windows" /> more detail: Server Error in '/' Application.
2
1503
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 media is configuring the background files. Do you wish to continue shutting down'. I've noticed when watching movies lately on windows media that after about 10-15 mins the movie starts to jump really badly and the only way to stop it is to stop the...
1
4157
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"/> The full error message is following: D:\websites\begaspnet2db\web.config(80): Build (web): It is an error to use a section registered as allowDefinition='MachineToApplication'
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.