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

problem with relative paths inside windows service?


Hi,

I have two application which 'evaluate'( New FileStream(path....) relative
path,
when evaluating the path inside a window service it always return something
like

C:\\WINNT\SYSTEM32\MyPath

While when evaluating it in a window application I get the correct path

both run from the same folder!!

Thanks.

Nov 16 '05 #1
4 4773
Julia,
This is because a windows service does not run from the folder you have
placed. The current directory for a Windows service is the
C:\Windows\System32.
Try using exact paths if possible.
--
http://dotnetjunkies.com/weblog/dotnut


"Julia" <co********@012.net.il> wrote in message
news:#S**************@TK2MSFTNGP12.phx.gbl...

Hi,

I have two application which 'evaluate'( New FileStream(path....) relative
path,
when evaluating the path inside a window service it always return something like

C:\\WINNT\SYSTEM32\MyPath

While when evaluating it in a window application I get the correct path

both run from the same folder!!

Thanks.

Nov 16 '05 #2
Julia,

If you want to get the path that the executing assembly is in, you
should get either the executing assembly (through a call to the static
GetExecutingAssembly method on the Assembly class) or the entry point (which
is your executable, I believe, obtained through a call to the static
GetEntryAssembly method on the Assembly class).

Once you have the Assembly instance, you can get the location through
the Location property on the assembly. From there, you can use the methods
on the Path class (in System.IO) to get the path of your files using a base
and a relative path.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Julia" <co********@012.net.il> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Hi,

I have two application which 'evaluate'( New FileStream(path....) relative
path,
when evaluating the path inside a window service it always return
something
like

C:\\WINNT\SYSTEM32\MyPath

While when evaluating it in a window application I get the correct path

both run from the same folder!!

Thanks.

Nov 16 '05 #3
Can I use the SetCurrentDirectory to set the running directory AFTER the
service was started
so all my relative paths function will work either in windows service or
window application?
"Ranjan" <ra*************@gmail.com> wrote in message
news:Oo****************@TK2MSFTNGP12.phx.gbl...
Julia,
This is because a windows service does not run from the folder you have
placed. The current directory for a Windows service is the
C:\Windows\System32.
Try using exact paths if possible.
--
http://dotnetjunkies.com/weblog/dotnut


"Julia" <co********@012.net.il> wrote in message
news:#S**************@TK2MSFTNGP12.phx.gbl...

Hi,

I have two application which 'evaluate'( New FileStream(path....) relative path,
when evaluating the path inside a window service it always return

something
like

C:\\WINNT\SYSTEM32\MyPath

While when evaluating it in a window application I get the correct path

both run from the same folder!!

Thanks.


Nov 16 '05 #4
It will not work out I am afraid once the Service has started. I will try
to research on this and find out. Thanks for giving me something to brood
overnight

Ranjan
--
http://dotnetjunkies.com/weblog/dotnut


"Julia" <co********@012.net.il> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Can I use the SetCurrentDirectory to set the running directory AFTER the
service was started
so all my relative paths function will work either in windows service or
window application?
"Ranjan" <ra*************@gmail.com> wrote in message
news:Oo****************@TK2MSFTNGP12.phx.gbl...
Julia,
This is because a windows service does not run from the folder you have
placed. The current directory for a Windows service is the
C:\Windows\System32.
Try using exact paths if possible.
--
http://dotnetjunkies.com/weblog/dotnut


"Julia" <co********@012.net.il> wrote in message
news:#S**************@TK2MSFTNGP12.phx.gbl...

Hi,

I have two application which 'evaluate'( New FileStream(path....) relative path,
when evaluating the path inside a window service it always return

something
like

C:\\WINNT\SYSTEM32\MyPath

While when evaluating it in a window application I get the correct path
both run from the same folder!!

Thanks.



Nov 16 '05 #5

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

Similar topics

5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
1
by: Dave | last post by:
I've been having trouble with the development of my ASP.NET site. The problem stems from the fact that I use one development server for many projects like www.devserver.com/project/, but each...
1
by: harvey | last post by:
Can anyone tell me how PHP handles paths? Do all functions require fully qualified paths or can some use relative paths? I'm having a problem with a foreach/glob() at the moment but have others...
5
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I have a virtual directory named Vehicles which serves a website. An ..aspx page in the Vehicles directory needs to display an image from a folder existing one folder above Vehicles. So I...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
2
by: BD | last post by:
Hi there. Using 8.2 on Windows. I have a situation where I have a db backup, which I want to deploy to a group of developer workstations. The target directory for the database files will be...
1
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have a piece of code that looks like this: XPathNavigator l_nav = xml_document.DocumentElement.CreateNavigator(); XslCompiledTransform l_xslt = new XslCompiledTransform();...
0
by: Gabriel Genellina | last post by:
En Sat, 18 Oct 2008 05:52:04 -0300, Stef Mientki <stef.mientki@gmail.com> escribió: Why don't you let the caller tell you its own location, using __file__? The above code is too much magic for...
1
by: desturrr | last post by:
I am having diffuculties while trying to make the path of my files relative. I am using an interface to hold my static variables in order not to mix them with my other codes , just implementing the...
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?
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...
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:
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
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...

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.