473,748 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic path

My service is running fine
when i give full path like this
"E:\c# windows\clamser vice\bin\Releas e\database"

but when i tried for dynamic

"/database"

it compiles well but when i go to Computer Management ->Services and start
it ,it gives

"The clamservice on local computer started and then stopped.Some services
stop automatically
if they have no work to do,for example performance logs and alerts service"
Feb 14 '06 #1
6 9179
Hi

Windows Service has a different initial Working directory.
Debug.WriteLine (Environment.Cu rrentDirectory. ToString());
The result will be C:\WINDOWS\syst em32, the result may differ according to
where you install Windows.

That is to say it will check the C:\WINDOWS\syst em32 for the relative path.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 14 '06 #2
i tried like this

pathdb=Environm ent.CurrentDire ctory.ToString( );

pathdb=pathdb+@ "\database" ;

p.Database.Path =pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=Configur ationSettings.A ppSettings.Get( "dbpath");

it runs fine

""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:D9******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi

Windows Service has a different initial Working directory.
Debug.WriteLine (Environment.Cu rrentDirectory. ToString());
The result will be C:\WINDOWS\syst em32, the result may differ according to
where you install Windows.

That is to say it will check the C:\WINDOWS\syst em32 for the relative
path.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 14 '06 #3
Ankit Aneja wrote:
i tried like this

pathdb=Environm ent.CurrentDire ctory.ToString( );

pathdb=pathdb+@ "\database" ;

p.Database.Path =pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=Configur ationSettings.A ppSettings.Get( "dbpath");

it runs fine


As Peter said, the CurrentDirector y property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\Syst em32, which I really hope you haven't...

You might want to look at Assembly.GetExe cutingAssembly( ) and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetMod ule(), then Module.FullyQua lifiedName.)

Jon

Feb 14 '06 #4
can u give me code example
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Ankit Aneja wrote:
i tried like this

pathdb=Environm ent.CurrentDire ctory.ToString( );

pathdb=pathdb+@ "\database" ;

p.Database.Path =pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=Configur ationSettings.A ppSettings.Get( "dbpath");

it runs fine


As Peter said, the CurrentDirector y property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\Syst em32, which I really hope you haven't...

You might want to look at Assembly.GetExe cutingAssembly( ) and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetMod ule(), then Module.FullyQua lifiedName.)

Jon

Feb 14 '06 #5
thanks
solved
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Ankit Aneja wrote:
i tried like this

pathdb=Environm ent.CurrentDire ctory.ToString( );

pathdb=pathdb+@ "\database" ;

p.Database.Path =pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=Configur ationSettings.A ppSettings.Get( "dbpath");

it runs fine


As Peter said, the CurrentDirector y property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\Syst em32, which I really hope you haven't...

You might want to look at Assembly.GetExe cutingAssembly( ) and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetMod ule(), then Module.FullyQua lifiedName.)

Jon

Feb 14 '06 #6
pathdb=System.I O.Path.GetDirec toryName(System .Reflection.Ass embly.GetEntryA ssembly().Locat ion);

pathdb=pathdb+@ "\database" ;

solved

"Ankit Aneja" <ef*****@newsgr oups.nospam> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...
can u give me code example
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Ankit Aneja wrote:
i tried like this

pathdb=Environm ent.CurrentDire ctory.ToString( );

pathdb=pathdb+@ "\database" ;

p.Database.Path =pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=Configur ationSettings.A ppSettings.Get( "dbpath");

it runs fine


As Peter said, the CurrentDirector y property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\Syst em32, which I really hope you haven't...

You might want to look at Assembly.GetExe cutingAssembly( ) and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetMod ule(), then Module.FullyQua lifiedName.)

Jon


Feb 14 '06 #7

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

Similar topics

3
1312
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example below... --
9
4489
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
2
1468
by: Justin | last post by:
Hi, I m doing a windows program using VB.net for my school assignment. I would like to ask is there a way for me to set a path (eg: //SamPC/data) as something dynamic such as dynamic properties in 'web.config' file or '.ini', which allows me to change the path mentioned above easily with compiling the whole program again.
1
1117
by: Director - Minvent | last post by:
I am having a problem! I am using the Task Pane control which MS gave out in their VBPowerPack. If I add an image to the task frame I have to use a physical path e.g. c:\connected.bmp as opposed to a more dynamic path such as System.Environment.CurrentDirectory & "\Images\Connected.bmp". With a picture box for example I would generally leave it blank and then add the image at runtime using something like :
7
22493
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We added an entry to the executable's .exe.config file to specify the URL, and under the 1.1 framework this worked well. Unfortunately, this is not working under the 2.0 framework. I see in the Reference.cs file under the web service reference the...
8
2257
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able to add comments at the bottom of each page, similar to the way the php, mysql, apache manuals work. PUNCHLINE_A:
1
1994
by: liam_herron | last post by:
I have compiled my boost-enabled C++ module and have it working when I explicity set my LD_LIBRARY_PATH before invoking the python2.4 interpreter. Now I don't want everyone to have to set this environment variable so I would like to devise a way that the module can load itself. My attempt was to create a module folder with the following __init__.py: -=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= import...
4
4898
by: Deere | last post by:
When I try to take a database field and change it with a function and return it...it will not display the image. The "Imageurl" does not convert to "src=" but stays as ImageUrl. id=Image2 will display ok ..and shows in view source as ....... <img id="gvwExample_ctl07_Image2" src=".\images\toys\1_16\thumb\t_15511.jpg" style="border-width:0px;" />
6
1847
by: Bill Spotz | last post by:
Hi, Is there a way to tell an executing python script where to look for dynamically-loaded libraries? My situation is that that I am developing python wrappers for a large software project. I create python wrappers with swig, and those extension modules link against dynamic libraries from the project. I have many test scripts that I would like to be able to run *prior* to installing these libraries into a standard location.
4
530
by: aarklon | last post by:
Hi all, recently a friend asked me is there any dynamic binding in C...?? to which i answered AFAIK it is in C++ only, but he says it is valid in C. if dynamic can be implemented via function pointers in C , can anyone give an example for dynamic binding in C...??
0
8996
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
8832
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
9333
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
9254
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
8255
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...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.