473,395 Members | 1,458 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,395 software developers and data experts.

How to change working dir in a NT service app?

Anyone know how to change the current working directory in a windows NT
service application written in C#?
It appears to start in the windows system32 directory not where the exe is
located which really screws up my app which acts on business objects in the
directory that the exe lives and therefore doesn't find the dependencies
because I'm not GAC'ing them. (And don't say just GAC 'em cause thats
another story I can't go into here!)
Is it even possible?

Nov 13 '05 #1
3 22021
"Berkflow" <sb*****@hotmail.com> wrote in message
news:Of*************@TK2MSFTNGP10.phx.gbl...
Anyone know how to change the current working directory in a windows NT
service application written in C#?
It appears to start in the windows system32 directory not where the exe is
located which really screws up my app which acts on business objects in the directory that the exe lives and therefore doesn't find the dependencies
because I'm not GAC'ing them. (And don't say just GAC 'em cause thats
another story I can't go into here!)
Is it even possible?


How about:

Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

Nov 13 '05 #2
Here is another way to do it.

System.IO.Directory.SetCurrentDirectory
(Application.StartupPath);
-----Original Message-----
Anyone know how to change the current working directory in a windows NTservice application written in C#?
It appears to start in the windows system32 directory not where the exe islocated which really screws up my app which acts on business objects in thedirectory that the exe lives and therefore doesn't find the dependenciesbecause I'm not GAC'ing them. (And don't say just GAC 'em cause thatsanother story I can't go into here!)
Is it even possible?

.

Nov 13 '05 #3
Thanks John - That worked perfectly!

"John Vottero" <Jo**@mvpsi.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
"Berkflow" <sb*****@hotmail.com> wrote in message
news:Of*************@TK2MSFTNGP10.phx.gbl...
Anyone know how to change the current working directory in a windows NT
service application written in C#?
It appears to start in the windows system32 directory not where the exe is located which really screws up my app which acts on business objects in the
directory that the exe lives and therefore doesn't find the dependencies
because I'm not GAC'ing them. (And don't say just GAC 'em cause thats
another story I can't go into here!)
Is it even possible?


How about:

Environment.CurrentDirectory =

System.AppDomain.CurrentDomain.BaseDirectory;

Nov 13 '05 #4

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

Similar topics

6
by: Chakkaradeep | last post by:
hi all, I have written a C# Service which is a Server accepting Clients,It is working fine when i connect from localhost but when i connect from any other machine to my machine , the service is...
4
by: utkarsh | last post by:
Hi, I want to develop a Window Service in C# that should be capable of sisplaying the a icon in the window tray. Based on some logic in service, icon should be changed to some other...
5
by: joeblast | last post by:
I have a Web service that gets the financial periods and hold a reference to a disconnected dataset built at initialization. Web methods work on the dataset inside the web service. Everything is...
22
by: Bob and Sharon Hiller | last post by:
I have an ASP page that was done in VBScript It is setup to read an Access database and I need to change it to read a Sql 2005 Database. The code that is used to open the Access Database: Set...
3
by: Luc | last post by:
Hi everyone, I had this strange problem. We are using web services for our entreprise applications. We are using IIS as the host for our webservices and IIS is configured to use integrated...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
4
by: Michael | last post by:
I have a repeater web control. Currently I want to change some row's color based on defined condition. Is there any code sample demonstrating how to accomplish it? Thanks.
2
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...
0
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...

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.